API net_nfc_error_e net_nfc_sign_records(ndef_message_s *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);
+ return net_nfc_util_sign_records((ndef_message_s *)msg,
+ begin_index, end_index, cert_file, password);
}
API net_nfc_error_e net_nfc_sign_ndef_message(ndef_message_s *msg,
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, };
+ net_nfc_target_info_s* target_info = NULL;
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if (target_info->devType != NET_NFC_FELICA_PICC)
rawdata.buffer = send_buffer;
rawdata.length = 6;
- return net_nfc_client_transceive_data(handle,
- &rawdata,
- callback,
- user_data);
+ return net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
}
API net_nfc_error_e net_nfc_client_felica_request_service(
nfc_transceive_data_callback callback,
void *user_data)
{
- net_nfc_target_info_s* target_info = NULL;
-
+ int i;
data_s rawdata;
-
data_s *IDm = NULL;
-
- uint32_t send_buffer_length;
- uint8_t* send_buffer = NULL;
uint8_t* temp = NULL;
+ uint8_t* send_buffer = NULL;
+ uint32_t send_buffer_length;
+ net_nfc_target_info_s* target_info = 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;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == area_service_list, NET_NFC_NULL_PARAMETER);
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if (target_info->devType != NET_NFC_FELICA_PICC)
}
if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if (IDm->length != 8)
return NET_NFC_OUT_OF_BOUND;
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)
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
rawdata.length = send_buffer_length;
net_nfc_error_e result = NET_NFC_OK;
- result = net_nfc_client_transceive_data(handle,
- &rawdata,
- callback,
- user_data);
+ result = net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
if (temp != NULL)
_net_nfc_util_free_mem(temp);
nfc_transceive_data_callback callback,
void *user_data)
{
- net_nfc_target_info_s* target_info = NULL;
-
data_s rawdata;
-
data_s *IDm = NULL;
-
uint8_t send_buffer[10] = { 0x00, };
+ net_nfc_target_info_s* target_info = NULL;
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if (target_info->devType != NET_NFC_FELICA_PICC)
}
if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if (IDm->length != 8)
return NET_NFC_OUT_OF_BOUND;
rawdata.buffer = send_buffer;
rawdata.length = 10;
- return net_nfc_client_transceive_data(handle,
- &rawdata,
- callback,
- user_data);
+ return net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
}
API net_nfc_error_e net_nfc_client_felica_read_without_encryption(
nfc_transceive_data_callback callback,
void *user_data)
{
- net_nfc_target_info_s* target_info = NULL;
-
+ int i;
data_s rawdata;
-
data_s *IDm = NULL;
-
- uint32_t send_buffer_length;
- uint8_t* send_buffer = NULL;
uint8_t* temp = NULL;
+ uint8_t* send_buffer = NULL;
+ uint32_t send_buffer_length;
+ net_nfc_target_info_s* target_info = NULL;
- int i;
-
- if (handle == NULL || service_list == NULL || block_list == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == service_list, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == block_list, NET_NFC_NULL_PARAMETER);
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if (target_info->devType != NET_NFC_FELICA_PICC)
}
if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if (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;
+ 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));
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
if (send_buffer == NULL)
return NET_NFC_ALLOC_FAIL;
rawdata.length = send_buffer_length;
net_nfc_error_e result = NET_NFC_OK;
- result = net_nfc_client_transceive_data(handle,
- &rawdata,
- callback,
- user_data);
+ result = net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
if (temp != NULL)
_net_nfc_util_free_mem(temp);
nfc_transceive_data_callback callback,
void *user_data)
{
- net_nfc_target_info_s* target_info = NULL;
-
+ int i;
data_s rawdata;
-
data_s *IDm = NULL;
-
- uint32_t send_buffer_length;
- uint8_t* send_buffer = NULL;
uint8_t* temp = NULL;
+ uint8_t* send_buffer = NULL;
+ uint32_t send_buffer_length;
+ net_nfc_target_info_s* target_info = NULL;
- int i;
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == block_list, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == service_list, NET_NFC_NULL_PARAMETER);
- if (handle == NULL || service_list == NULL ||
- block_list == NULL || data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
- 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 (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if (target_info->devType != NET_NFC_FELICA_PICC)
}
if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if (IDm->length != 8)
return NET_NFC_OUT_OF_BOUND;
+ 1 + number_of_blocks + data->length;
_net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
net_nfc_error_e result = NET_NFC_OK;
- result = net_nfc_client_transceive_data(handle,
- &rawdata,
- callback,
- user_data);
+ result = net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
if (temp != NULL)
_net_nfc_util_free_mem(temp);
nfc_transceive_data_callback callback,
void *user_data)
{
- net_nfc_target_info_s* target_info = NULL;
-
data_s rawdata;
-
data_s *IDm = NULL;
-
uint8_t send_buffer[10] = { 0x00, };
+ net_nfc_target_info_s* target_info = NULL;
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if (target_info->devType != NET_NFC_FELICA_PICC)
}
if (net_nfc_get_tag_info_value(target_info, FELICA_TAG_KEY, &IDm) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if (IDm->length != 8)
return NET_NFC_OUT_OF_BOUND;
rawdata.buffer = send_buffer;
rawdata.length = 10;
- return net_nfc_client_transceive_data(handle,
- &rawdata,
- callback,
- user_data);
+ return net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
}
API net_nfc_error_e net_nfc_client_jewel_read_id(net_nfc_target_handle_s *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, };
+ net_nfc_target_info_s *target_info = NULL;
- if(handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if(target_info->devType != NET_NFC_JEWEL_PICC)
API net_nfc_error_e net_nfc_client_jewel_read_byte(net_nfc_target_handle_s *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_s *UID = NULL;
-
uint8_t send_buffer[9] = {0x00, };
+ net_nfc_target_info_s *target_info = NULL;
- if(handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if(block > 0xE || byte > 0x7 )
- return NET_NFC_OUT_OF_BOUND;
+ RETVM_IF(block > 0xE || byte > 0x7, NET_NFC_OUT_OF_BOUND,
+ "block value is = [0x%x], byte value is = [0x%x]", block, byte);
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if(target_info->devType != NET_NFC_JEWEL_PICC)
}
if(net_nfc_get_tag_info_value(target_info, JEWEL_TAG_KEY, &UID) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if(UID->length != 4)
return NET_NFC_OUT_OF_BOUND;
API net_nfc_error_e net_nfc_client_jewel_read_all(net_nfc_target_handle_s *handle,
nfc_transceive_data_callback callback, void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
-
data_s rawdata;
-
data_s *UID = NULL;
-
uint8_t send_buffer[9] = {0x00, };
+ net_nfc_target_info_s *target_info = NULL;
- if(handle == NULL )
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if(target_info->devType != NET_NFC_JEWEL_PICC)
}
if(net_nfc_get_tag_info_value(target_info, JEWEL_TAG_KEY, &UID) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if(UID->length != 4)
return NET_NFC_OUT_OF_BOUND;
nfc_transceive_callback callback,
void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
data_s rawdata;
data_s *UID = NULL;
uint8_t send_buffer[9] = {0x00, };
+ net_nfc_target_info_s *target_info = NULL;
- if(handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, 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;
+ RETVM_IF(block > 0xE || byte > 0x7, NET_NFC_OUT_OF_BOUND,
+ "block value is = [0x%x], byte value is = [0x%x]", block, byte);
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
if(net_nfc_get_tag_info_value(target_info, JEWEL_TAG_KEY, &UID) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if(UID->length != 4)
return NET_NFC_OUT_OF_BOUND;
nfc_transceive_callback callback,
void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
-
data_s rawdata;
-
data_s *UID = NULL;
-
uint8_t send_buffer[9] = {0x00, };
+ net_nfc_target_info_s *target_info = NULL;
- if(handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if(block > 0xE || byte > 0x7 )
- return NET_NFC_OUT_OF_BOUND;
+ RETVM_IF(block > 0xE || byte > 0x7, NET_NFC_OUT_OF_BOUND,
+ "block value is = [0x%x], byte value is = [0x%x]", block, byte);
- if(net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NO_DATA_FOUND;
+
if(target_info->devType != NET_NFC_JEWEL_PICC)
{
NFC_ERR("only Jewel tag is available(TAG=%d)", target_info->devType);
}
if(net_nfc_get_tag_info_value(target_info, JEWEL_TAG_KEY, &UID) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
if(UID->length != 4)
return NET_NFC_OUT_OF_BOUND;
void *callback,
void *user_data)
{
- net_nfc_target_info_s* target_info = NULL;
data_s rawdata;
data_s *UID = NULL;
- uint8_t* send_buffer = NULL;
uint8_t* temp = NULL;
+ net_nfc_error_e result;
int send_buffer_length = 0;
+ uint8_t* send_buffer = NULL;
uint8_t sector_to_block = 0;
- net_nfc_error_e result;
-
- if (handle == NULL || auth_key == NULL)
- return NET_NFC_NULL_PARAMETER;
+ net_nfc_target_info_s* target_info = NULL;
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == auth_key, NET_NFC_NULL_PARAMETER);
- if (auth_key->length != 6)
- return NET_NFC_OUT_OF_BOUND;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
+ RETVM_IF(auth_key->length != 6, NET_NFC_OUT_OF_BOUND,
+ "auth_key->length(%d) != 6", auth_key->length);
target_info = net_nfc_client_tag_get_client_target_info();
}
if (net_nfc_get_tag_info_value(target_info, MIFARE_TAG_KEY, &UID) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
switch (target_info->devType)
{
/* cmd + addr + UID + AUTH_KEY + CRC_A */
send_buffer_length = 1 + 1 + UID->length + auth_key->length + 2;
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+ if (NULL == send_buffer)
{
net_nfc_free_data(UID);
return NET_NFC_ALLOC_FAIL;
void *callback,
void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
data_s rawdata;
data_s *UID = NULL;
- uint8_t* send_buffer = NULL;
uint8_t* temp = NULL;
+ net_nfc_error_e result;
int send_buffer_length = 0;
+ uint8_t* send_buffer = NULL;
uint8_t sector_to_block = 0;
- net_nfc_error_e result;
+ net_nfc_target_info_s *target_info = NULL;
- if (handle == NULL || auth_key == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == auth_key, NET_NFC_NULL_PARAMETER);
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
+ RETVM_IF(auth_key->length != 6, NET_NFC_OUT_OF_BOUND,
+ "auth_key->length(%d) != 6", auth_key->length);
- if (auth_key->length != 6)
- return NET_NFC_OUT_OF_BOUND;
target_info = net_nfc_client_tag_get_client_target_info();
}
if (net_nfc_get_tag_info_value(target_info, MIFARE_TAG_KEY, &UID) != NET_NFC_OK)
- {
return NET_NFC_NO_DATA_FOUND;
- }
switch (target_info->devType)
{
sector_to_block = sector * MIFARE_BLOCK_4 + 3;
else
{
- sector_to_block = (31 * MIFARE_BLOCK_4 + 3)
- + (sector - 32)
+ sector_to_block = (31 * MIFARE_BLOCK_4 + 3) + (sector - 32)
* MIFARE_BLOCK_16 + 15;
}
break;
/* cmd + addr + UID + AUTH_KEY + CRC_A */
send_buffer_length = 1 + 1 + UID->length + auth_key->length + 2;
- _net_nfc_util_alloc_mem(send_buffer, send_buffer_length
- * sizeof(uint8_t));
- if (send_buffer == NULL)
+ _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+ if (NULL == send_buffer)
{
net_nfc_free_data(UID);
return NET_NFC_ALLOC_FAIL;
API net_nfc_error_e net_nfc_client_mifare_read(net_nfc_target_handle_s *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};
+ net_nfc_target_info_s *target_info = NULL;
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
rawdata.buffer = send_buffer;
rawdata.length = 4;
- return net_nfc_client_transceive_data(handle,
- &rawdata,
- callback,
- user_data);
+ return net_nfc_client_transceive_data(handle, &rawdata, callback, user_data);
}
API net_nfc_error_e net_nfc_client_mifare_write_block(
void *callback,
void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
data_s rawdata;
+ net_nfc_error_e result;
uint8_t* send_buffer = NULL;
uint32_t send_buffer_length = 0;
- net_nfc_error_e result;
-
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ net_nfc_target_info_s *target_info = NULL;
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
-
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NOT_INITIALIZED;
if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
/* cmd + addr + page + CRC */
send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE + 2;
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
/* cmd + addr + page + CRC */
send_buffer_length = 1 + 1 + data->length + 2;
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
memcpy(temp, data->buffer, data->length);
}
-
}
else
{
-
if (data->length > MIFARE_BLOCK_SIZE)
{
uint8_t* temp = NULL;
/* cmd + addr + page + CRC */
send_buffer_length = 1 + 1 + MIFARE_BLOCK_SIZE + 2;
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
send_buffer_length = 1 + 1 + data->length + 2;
_net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
void *callback,
void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
+ data_s rawdata;
+ net_nfc_error_e result;
uint8_t* send_buffer = NULL;
uint32_t send_buffer_length = 0;
- net_nfc_error_e result;
- data_s rawdata;
+ net_nfc_target_info_s *target_info = NULL;
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NOT_INITIALIZED;
if (target_info->devType < NET_NFC_MIFARE_MINI_PICC ||
send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE + 2;
_net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
send_buffer_length = 1 + 1 + data->length + 2;
_net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
/* cmd + addr + page + CRC */
send_buffer_length = 1 + 1 + MIFARE_PAGE_SIZE + 2;
- _net_nfc_util_alloc_mem(send_buffer,
- send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ _net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
send_buffer_length = 1 + 1 + data->length + 2;
_net_nfc_util_alloc_mem(send_buffer, send_buffer_length * sizeof(uint8_t));
- if (send_buffer == NULL)
+ if (NULL == send_buffer)
return NET_NFC_ALLOC_FAIL;
temp = send_buffer;
void *callback,
void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
-
data_s rawdata;
-
uint8_t send_buffer[8] = { 0 };
+ net_nfc_target_info_s *target_info = NULL;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
rawdata.buffer = send_buffer;
rawdata.length = 8;
- return net_nfc_client_transceive(handle, &rawdata, callback,
- user_data);
+ return net_nfc_client_transceive(handle, &rawdata, callback, user_data);
}
API net_nfc_error_e net_nfc_client_mifare_decrement(
void *callback,
void *user_data)
{
- net_nfc_target_info_s *target_info = NULL;
-
data_s rawdata;
-
uint8_t send_buffer[8] = { 0 };
+ net_nfc_target_info_s *target_info = NULL;
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, 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)
{
rawdata.buffer = send_buffer;
rawdata.length = 8;
- return net_nfc_client_transceive(handle, &rawdata, callback,
- user_data);
+ return net_nfc_client_transceive(handle, &rawdata, callback, user_data);
}
API net_nfc_error_e net_nfc_client_mifare_transfer(net_nfc_target_handle_s *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 };
+ net_nfc_target_info_s *target_info = NULL;
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
rawdata.buffer = send_buffer;
rawdata.length = 4;
- return net_nfc_client_transceive(handle, &rawdata, callback,
- user_data);
+ return net_nfc_client_transceive(handle, &rawdata, callback, user_data);
}
API net_nfc_error_e net_nfc_client_mifare_restore(net_nfc_target_handle_s *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 };
+ net_nfc_target_info_s *target_info = NULL;
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if (net_nfc_client_tag_is_connected() == FALSE)
- return NET_NFC_OPERATION_FAIL;
+ RETV_IF(net_nfc_client_tag_is_connected() == FALSE, NET_NFC_OPERATION_FAIL);
target_info = net_nfc_client_tag_get_client_target_info();
rawdata.buffer = send_buffer;
rawdata.length = 4;
- return net_nfc_client_transceive(handle, &rawdata, callback,
- user_data);
+ return net_nfc_client_transceive(handle, &rawdata, callback, user_data);
}
API net_nfc_error_e net_nfc_client_mifare_create_default_key(data_s** key)
{
- if (key == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == key, NET_NFC_NULL_PARAMETER);
return net_nfc_create_data(key, default_key, 6);
}
API net_nfc_error_e net_nfc_client_mifare_create_application_directory_key(
data_s** key)
{
- if (key == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == key, NET_NFC_NULL_PARAMETER);
return net_nfc_create_data(key, mad_key, 6);
}
-API net_nfc_error_e net_nfc_client_mifare_create_net_nfc_forum_key(data_s** key)
+API net_nfc_error_e net_nfc_client_mifare_create_net_nfc_forum_key(
+ data_s** key)
{
- if (key == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == key, NET_NFC_NULL_PARAMETER);
return net_nfc_create_data(key, net_nfc_forum_key, 6);
}
API net_nfc_error_e net_nfc_get_tag_type(net_nfc_target_info_s *target_info,
net_nfc_target_type_e *type)
{
- if (type == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == type, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == target_info, NET_NFC_INVALID_HANDLE);
*type = NET_NFC_UNKNOWN_TARGET;
-
- if (target_info == NULL)
- return NET_NFC_INVALID_HANDLE;
-
*type = target_info->devType;
+
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_handle(net_nfc_target_info_s *target_info,
net_nfc_target_handle_s **handle)
{
- if (handle == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == target_info, NET_NFC_INVALID_HANDLE);
*handle = NULL;
-
- if (target_info == NULL)
- return NET_NFC_INVALID_HANDLE;
-
*handle = target_info->handle;
+
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_ndef_support(
net_nfc_target_info_s *target_info, bool *is_support)
{
- if (target_info == NULL || is_support == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == is_support, NET_NFC_NULL_PARAMETER);
*is_support = (bool)target_info->is_ndef_supported;
+
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_max_data_size(
- net_nfc_target_info_s *target_info, uint32_t * max_size)
+ net_nfc_target_info_s *target_info, uint32_t *max_size)
{
- if (target_info == NULL || max_size == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == max_size, NET_NFC_NULL_PARAMETER);
*max_size = target_info->maxDataSize;
+
return NET_NFC_OK;
}
API net_nfc_error_e net_nfc_get_tag_actual_data_size(
net_nfc_target_info_s *target_info, uint32_t *actual_data)
{
- if (target_info == NULL || actual_data == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == actual_data, NET_NFC_NULL_PARAMETER);
*actual_data = target_info->actualDataSize;
+
return NET_NFC_OK;
}
{
int i = 0;
- if (keys == NULL || number_of_keys == NULL || target_info == NULL)
- return NET_NFC_NULL_PARAMETER;
-
- if (target_info->tag_info_list == NULL)
- return NET_NFC_NO_DATA_FOUND;
+ RETV_IF(NULL == keys, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == number_of_keys, NET_NFC_NULL_PARAMETER);
- if (target_info->number_of_keys <= 0)
- return NET_NFC_NO_DATA_FOUND;
+ RETV_IF(NULL == target_info->tag_info_list, NET_NFC_NO_DATA_FOUND);
+ RETV_IF(target_info->number_of_keys <= 0, NET_NFC_NO_DATA_FOUND);
if (target_info->keylist != NULL)
{
}
_net_nfc_util_alloc_mem(*keys, target_info->number_of_keys * sizeof(char *));
- if (*keys == NULL)
+ if (NULL == *keys)
return NET_NFC_ALLOC_FAIL;
net_nfc_tag_info_s *tag_info = target_info->tag_info_list;
int i;
net_nfc_tag_info_s *tag_info;
- if (target_info == NULL || key == NULL || value == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == key, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == value, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == target_info, NET_NFC_NULL_PARAMETER);
- if (target_info->tag_info_list == NULL)
- return NET_NFC_NO_DATA_FOUND;
+ RETV_IF(NULL == target_info->tag_info_list, NET_NFC_NO_DATA_FOUND);
tag_info = target_info->tag_info_list;
- for (i=0;i < target_info->number_of_keys;i++, tag_info++)
+ for (i = 0; i < target_info->number_of_keys; i++, tag_info++)
{
if (strcmp(key, tag_info->key) == 0)
{
- if (tag_info->value == NULL)
+ if (NULL == tag_info->value)
{
return NET_NFC_NO_DATA_FOUND;
}
{
net_nfc_target_info_s *temp = NULL;
- if (origin == NULL || result == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == origin, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == result, NET_NFC_NULL_PARAMETER);
_net_nfc_util_alloc_mem(temp, sizeof(net_nfc_target_info_s));
- if (temp == NULL)
+ if (NULL == temp)
return NET_NFC_ALLOC_FAIL;
temp->ndefCardState = origin->ndefCardState;
temp->is_ndef_supported = origin->is_ndef_supported;
temp->number_of_keys = origin->number_of_keys;
- if (temp->number_of_keys > 0)
+ if (0 < temp->number_of_keys)
{
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_alloc_mem(temp->tag_info_list,
+ temp->number_of_keys * sizeof(net_nfc_tag_info_s));
+
+ if (NULL == temp->tag_info_list)
{
_net_nfc_util_free_mem(temp);
return NET_NFC_ALLOC_FAIL;
for (i = 0; i < origin->number_of_keys; i++)
{
if (origin->tag_info_list[i].key != NULL)
- _net_nfc_util_strdup(temp->tag_info_list[i].key, origin->tag_info_list[i].key);
+ {
+ _net_nfc_util_strdup(temp->tag_info_list[i].key,
+ origin->tag_info_list[i].key);
+ }
if (origin->tag_info_list[i].value != NULL)
{
data_s *data = origin->tag_info_list[i].value;
- net_nfc_create_data(&temp->tag_info_list[i].value, data->buffer, data->length);
+ net_nfc_create_data(&temp->tag_info_list[i].value,
+ data->buffer, data->length);
}
}
}
- if (origin->raw_data.length > 0)
+ if (0 < origin->raw_data.length)
{
net_nfc_util_alloc_data(&temp->raw_data, origin->raw_data.length);
memcpy(temp->raw_data.buffer, origin->raw_data.buffer, temp->raw_data.length);
{
net_nfc_tag_info_s *list = NULL;
- if (info == NULL)
+ if (NULL == info)
return NET_NFC_NULL_PARAMETER;
list = info->tag_info_list;
{
net_nfc_error_e result;
- if (target_info == NULL)
+ if (NULL == target_info)
return NET_NFC_NULL_PARAMETER;
result = _release_tag_info(target_info);
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)
+ net_nfc_target_type_e devType, data_s *data)
{
- data_s transceive_info = { NULL, };
GVariant *variant;
+ data_s transceive_info = { NULL, };
- if (data == NULL)
- {
- NFC_ERR("data is empty");
- return NULL;
- }
+ RETV_IF(NULL == data, NULL);
switch (devType)
{
case NET_NFC_MIFARE_1K_PICC :
case NET_NFC_MIFARE_4K_PICC :
case NET_NFC_MIFARE_ULTRA_PICC :
- if (net_nfc_util_alloc_data(&transceive_info,
- data->length + 2) == true)
+ if (net_nfc_util_alloc_data(&transceive_info, data->length + 2) == true)
{
- memcpy(transceive_info.buffer,
- data->buffer,
- data->length);
+ memcpy(transceive_info.buffer, data->buffer, data->length);
- net_nfc_util_compute_CRC(CRC_A,
- transceive_info.buffer,
- transceive_info.length);
+ net_nfc_util_compute_CRC(CRC_A, transceive_info.buffer, transceive_info.length);
}
break;
if (net_nfc_util_alloc_data(&transceive_info, 9) == true)
{
- memcpy(transceive_info.buffer,
- data->buffer,
- data->length);
+ memcpy(transceive_info.buffer, data->buffer, data->length);
- net_nfc_util_compute_CRC(CRC_B,
- transceive_info.buffer,
- transceive_info.length);
+ net_nfc_util_compute_CRC(CRC_B, transceive_info.buffer, transceive_info.length);
}
break;
default :
- if(net_nfc_util_alloc_data(&transceive_info,
- data->length) == true)
- {
- memcpy(transceive_info.buffer,
- data->buffer,
- data->length);
- }
+ if(net_nfc_util_alloc_data(&transceive_info, data->length) == true)
+ memcpy(transceive_info.buffer, data->buffer, data->length);
+
break;
}
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;
+ gboolean ret;
GError *error = NULL;
+ data_s resp = { NULL, };
+ GVariant *out_data = NULL;
+ net_nfc_error_e out_result;
+ nfc_transceive_data_callback callback;
+ NetNfcCallback *func_data = user_data;
g_assert(user_data != NULL);
- if (net_nfc_gdbus_transceive_call_transceive_data_finish(
+ ret = net_nfc_gdbus_transceive_call_transceive_data_finish(
NET_NFC_GDBUS_TRANSCEIVE(source_object),
(gint *)&out_result,
&out_data,
res,
- &error) == FALSE)
+ &error);
+
+ if (FALSE == ret)
{
NFC_ERR("Can not finish transceive: %s", error->message);
g_error_free(error);
static void transceive_call(GObject *source_object,
GAsyncResult *res, gpointer user_data)
{
- NetNfcCallback *func_data = (NetNfcCallback *)user_data;
- net_nfc_error_e out_result;
+ gboolean ret;
GError *error = NULL;
+ net_nfc_error_e out_result;
+ nfc_transceive_callback callback;
+ NetNfcCallback *func_data = user_data;
g_assert(user_data != NULL);
- if (net_nfc_gdbus_transceive_call_transceive_finish(
+ ret = net_nfc_gdbus_transceive_call_transceive_finish(
NET_NFC_GDBUS_TRANSCEIVE(source_object),
(gint *)&out_result,
res,
- &error) == FALSE)
+ &error);
+
+ if (FALSE == ret)
{
NFC_ERR("Can not finish transceive: %s", error->message);
g_error_free(error);
out_result = NET_NFC_IPC_FAIL;
}
- if (func_data->callback != NULL)
+ if (func_data->callback)
{
- ((nfc_transceive_callback)func_data->callback)(
- out_result,
- func_data->user_data);
+ callback = (nfc_transceive_callback)func_data->callback;
+ callback(out_result, func_data->user_data);
}
g_free(func_data);
API net_nfc_error_e net_nfc_client_transceive(net_nfc_target_handle_s *handle,
data_s *rawdata, nfc_transceive_callback callback, void *user_data)
{
- net_nfc_target_info_s *target_info;
- NetNfcCallback *funcdata;
GVariant *arg_data;
+ NetNfcCallback *funcdata;
+ net_nfc_target_info_s *target_info;
- if (transceive_proxy == NULL)
+ if (NULL == transceive_proxy)
{
NFC_ERR("Can not get TransceiveProxy");
return NET_NFC_NOT_INITIALIZED;
}
-
- if (handle == NULL || rawdata == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
/* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_INVALID_STATE;
- }
+ RETV_IF(net_nfc_client_manager_is_activated() == false, NET_NFC_INVALID_STATE);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL || target_info->handle == NULL)
+
+ if (NULL == target_info)
+ {
+ NFC_ERR("target_info is NULL");
+ return NET_NFC_NOT_CONNECTED;
+ }
+
+ if (NULL == target_info->handle)
+ {
+ NFC_ERR("target_info->handle is NULL");
return NET_NFC_NOT_CONNECTED;
+ }
NFC_DBG("send request :: transceive = [%p]", handle);
- arg_data = transceive_data_to_transceive_variant(target_info->devType,
- rawdata);
- if (arg_data == NULL) {
+ arg_data = transceive_data_to_transceive_variant(target_info->devType, rawdata);
+ if (NULL == arg_data)
return NET_NFC_INVALID_PARAM;
- }
funcdata = g_try_new0(NetNfcCallback, 1);
- if (funcdata == NULL) {
+ if (NULL == funcdata)
+ {
g_variant_unref(arg_data);
return NET_NFC_ALLOC_FAIL;
API net_nfc_error_e net_nfc_client_transceive_data(net_nfc_target_handle_s *handle,
data_s *rawdata, nfc_transceive_data_callback callback, void *user_data)
{
- net_nfc_target_info_s *target_info;
- NetNfcCallback *funcdata;
GVariant *arg_data;
+ NetNfcCallback *funcdata;
+ net_nfc_target_info_s *target_info;
- if (transceive_proxy == NULL)
- {
- NFC_ERR("Can not get TransceiveProxy");
-
- return NET_NFC_NOT_INITIALIZED;
- }
+ RETV_IF(NULL == transceive_proxy, NET_NFC_NOT_INITIALIZED);
- if (handle == NULL || rawdata == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
/* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_INVALID_STATE;
- }
+ RETV_IF(net_nfc_client_manager_is_activated() == false, NET_NFC_INVALID_STATE);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL || target_info->handle == NULL)
+
+ if (NULL == target_info)
+ {
+ NFC_ERR("target_info is NULL");
+ return NET_NFC_NOT_CONNECTED;
+ }
+
+ if (NULL == target_info->handle)
+ {
+ NFC_ERR("target_info->handle is NULL");
return NET_NFC_NOT_CONNECTED;
+ }
NFC_DBG("send request :: transceive = [%p]", handle);
- arg_data = transceive_data_to_transceive_variant(target_info->devType,
- rawdata);
- if (arg_data == NULL) {
+ arg_data = transceive_data_to_transceive_variant(target_info->devType, rawdata);
+ if (NULL == arg_data)
return NET_NFC_INVALID_PARAM;
- }
funcdata = g_try_new0(NetNfcCallback, 1);
- if (funcdata == NULL) {
+ if (NULL == funcdata)
+ {
g_variant_unref(arg_data);
return NET_NFC_ALLOC_FAIL;
API net_nfc_error_e net_nfc_client_transceive_sync(net_nfc_target_handle_s *handle,
data_s *rawdata)
{
+ gboolean ret;
+ GVariant *arg_data;
+ GError *error = NULL;
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)
- {
- NFC_ERR("Can not get TransceiveProxy");
+ RETV_IF(NULL == transceive_proxy, NET_NFC_NOT_INITIALIZED);
- return NET_NFC_NOT_INITIALIZED;
- }
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
/* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_INVALID_STATE;
- }
+ RETV_IF(net_nfc_client_manager_is_activated() == false, NET_NFC_INVALID_STATE);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL || target_info->handle == NULL)
+
+ if (NULL == target_info)
+ {
+ NFC_ERR("target_info is NULL");
+ return NET_NFC_NOT_CONNECTED;
+ }
+
+ if (NULL == target_info->handle)
+ {
+ NFC_ERR("target_info->handle is NULL");
return NET_NFC_NOT_CONNECTED;
+ }
NFC_DBG("send request :: transceive = [%p]", handle);
- arg_data = transceive_data_to_transceive_variant(target_info->devType,
- rawdata);
- if (arg_data == NULL)
+ arg_data = transceive_data_to_transceive_variant(target_info->devType, rawdata);
+ if (NULL == arg_data)
return NET_NFC_ALLOC_FAIL;
- if (net_nfc_gdbus_transceive_call_transceive_sync(transceive_proxy,
+ ret = net_nfc_gdbus_transceive_call_transceive_sync(transceive_proxy,
GPOINTER_TO_UINT(handle),
target_info->devType,
arg_data,
net_nfc_client_gdbus_get_privilege(),
(gint *)&out_result,
NULL,
- &error) == FALSE)
+ &error);
+
+ if (FALSE == ret)
{
- NFC_ERR("Transceive (sync call) failed: %s",
- error->message);
+ NFC_ERR("Transceive (sync call) failed: %s", error->message);
g_error_free(error);
out_result = NET_NFC_IPC_FAIL;
API net_nfc_error_e net_nfc_client_transceive_data_sync(
net_nfc_target_handle_s *handle, data_s *rawdata, data_s **response)
{
+ gboolean ret;
+ GVariant *arg_data;
+ GError *error = NULL;
+ GVariant *out_data = NULL;
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)
- {
- NFC_ERR("Can not get TransceiveProxy");
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
- return NET_NFC_NOT_INITIALIZED;
- }
+ RETV_IF(NULL == transceive_proxy, NET_NFC_NOT_INITIALIZED);
/* prevent executing daemon when nfc is off */
- if (net_nfc_client_manager_is_activated() == false) {
- return NET_NFC_INVALID_STATE;
- }
+ RETV_IF(net_nfc_client_manager_is_activated() == false, NET_NFC_INVALID_STATE);
target_info = net_nfc_client_tag_get_client_target_info();
- if (target_info == NULL || target_info->handle == NULL)
+ if (NULL == target_info)
+ {
+ NFC_ERR("target_info is NULL");
+ return NET_NFC_NOT_CONNECTED;
+ }
+
+ if (NULL == target_info->handle)
+ {
+ NFC_ERR("target_info->handle is NULL");
return NET_NFC_NOT_CONNECTED;
+ }
NFC_DBG("send request :: transceive = [%p]", handle);
- arg_data = transceive_data_to_transceive_variant(target_info->devType,
- rawdata);
- if (arg_data == NULL)
+ arg_data = transceive_data_to_transceive_variant(target_info->devType, rawdata);
+ if (NULL == arg_data)
return NET_NFC_ALLOC_FAIL;
- if (net_nfc_gdbus_transceive_call_transceive_data_sync(
+ ret = net_nfc_gdbus_transceive_call_transceive_data_sync(
transceive_proxy,
GPOINTER_TO_UINT(handle),
target_info->devType,
(gint *)&out_result,
&out_data,
NULL,
- &error) == FALSE)
+ &error);
+
+ if (FALSE == ret)
{
- NFC_ERR("Transceive (sync call) failed: %s",
- error->message);
+ NFC_ERR("Transceive (sync call) failed: %s", error->message);
g_error_free(error);
out_result = NET_NFC_IPC_FAIL;
}
if (response && out_data != NULL)
- {
*response = net_nfc_util_gdbus_variant_to_data(out_data);
- }
return out_result;
}
"/org/tizen/NetNfcService/Transceive",
NULL,
&error);
- if (transceive_proxy == NULL)
+ if (NULL == transceive_proxy)
{
NFC_ERR("Can not create proxy : %s", error->message);
g_error_free(error);
log_tag = LOG_SERVER_TAG;
}
-
API void __net_nfc_util_free_mem(void **mem, char *filename, unsigned int line)
{
- if (mem == NULL)
+ if (NULL == mem)
{
- SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in mem free util, mem is NULL", filename, line);
+ SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in mem free util, mem is NULL",
+ filename, line);
return;
}
- if (*mem == NULL)
+ if (NULL == *mem)
{
- SECURE_LOGD("FILE: %s, LINE:%d, Invalid Parameter in mem free util, *mem is NULL", filename, line);
+ SECURE_LOGD("FILE: %s, LINE:%d, Invalid Parameter in mem free util, *mem is NULL",
+ filename, line);
return;
}
*mem = NULL;
}
-API void __net_nfc_util_alloc_mem(void **mem, int size, char *filename, unsigned int line)
+API void __net_nfc_util_alloc_mem(void **mem, int size, char *filename,
+ unsigned int line)
{
- if (mem == NULL || size <= 0)
+ if (NULL == mem || size <= 0)
{
- SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in mem alloc util, mem [%p], size [%d]", filename, line, mem, size);
+ SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in mem alloc util",
+ "mem [%p], size [%d]", filename, line, mem, size);
return;
}
if (*mem != NULL)
{
- SECURE_LOGD("FILE: %s, LINE:%d, WARNING: Pointer is not NULL, mem [%p]", filename, line, *mem);
+ SECURE_LOGD("FILE: %s, LINE:%d, WARNING: Pointer is not NULL, mem [%p]",
+ filename, line, *mem);
}
*mem = g_malloc0(size);
- if (*mem == NULL)
+ if (NULL == *mem)
{
- SECURE_LOGD("FILE: %s, LINE:%d, Allocation is failed, size [%d]", filename, line, size);
+ SECURE_LOGD("FILE: %s, LINE:%d, Allocation is failed, size [%d]",
+ filename, line, size);
}
}
-API void __net_nfc_util_strdup(char **output, const char *origin, char *filename, unsigned int line)
+API void __net_nfc_util_strdup(char **output, const char *origin, char *filename,
+ unsigned int line)
{
- if (output == NULL || origin == NULL)
+ if (NULL == output || NULL == origin)
{
- SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in strdup, output [%p], origin [%p]", filename, line, output, origin);
+ SECURE_LOGD("FILE: %s, LINE:%d, Invalid parameter in strdup",
+ "output [%p], origin [%p]", filename, line, output, origin);
return;
}
if (*output != NULL)
{
- SECURE_LOGD("FILE: %s, LINE:%d, WARNING: Pointer is not NULL, mem [%p]", filename, line, *output);
+ SECURE_LOGD("FILE: %s, LINE:%d, WARNING: Pointer is not NULL, mem [%p]",
+ filename, line, *output);
}
*output = g_strdup(origin);
- if (*output == NULL)
- {
+ if (NULL == *output)
SECURE_LOGD("FILE: %s, LINE:%d, strdup failed", filename, line);
- }
}
API bool net_nfc_util_alloc_data(data_s *data, uint32_t length)
{
- if (data == NULL || length == 0)
- return false;
+ RETV_IF(0 == length, false);
+ RETV_IF(NULL == data, false);
_net_nfc_util_alloc_mem(data->buffer, length);
- if (data->buffer == NULL)
+ if (NULL == data->buffer)
return false;
data->length = length;
API void net_nfc_util_free_data(data_s *data)
{
- if (data == NULL || data->buffer == NULL)
- return;
+ RET_IF(NULL == data);
+ RET_IF(NULL == data->buffer);
_net_nfc_util_free_mem(data->buffer);
data->length = 0;
}
-net_nfc_conn_handover_carrier_state_e net_nfc_util_get_cps(net_nfc_conn_handover_carrier_type_e carrier_type)
+net_nfc_conn_handover_carrier_state_e net_nfc_util_get_cps(
+ net_nfc_conn_handover_carrier_type_e carrier_type)
{
net_nfc_conn_handover_carrier_state_e cps = NET_NFC_CONN_HANDOVER_CARRIER_INACTIVATE;
- if (carrier_type == NET_NFC_CONN_HANDOVER_CARRIER_BT)
+ if (NET_NFC_CONN_HANDOVER_CARRIER_BT== carrier_type)
{
int ret = bluetooth_check_adapter();
break;
}
}
- else if (carrier_type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)
+ else if (NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS == carrier_type)
{
int wifi_state = 0;
_net_nfc_util_alloc_mem(bt_addr, BLUETOOTH_ADDRESS_LENGTH);
if (bt_addr != NULL)
{
- if (net_nfc_util_get_cps(NET_NFC_CONN_HANDOVER_CARRIER_BT) != NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE)
+ net_nfc_conn_handover_carrier_state_e ret;
+
+ ret = net_nfc_util_get_cps(NET_NFC_CONN_HANDOVER_CARRIER_BT);
+
+ if (ret != NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE)
{
// bt power is off. so get bt address from configuration file.
FILE *fp = NULL;
if ((fp = fopen(HIDDEN_BT_ADDR_FILE, "r")) != NULL)
{
- unsigned char temp[BLUETOOTH_ADDRESS_LENGTH * 2] = { 0, };
-
int ch;
- int count = 0;
int i = 0;
+ int count = 0;
+ unsigned char temp[BLUETOOTH_ADDRESS_LENGTH * 2] = { 0, };
while ((ch = fgetc(fp)) != EOF && count < BLUETOOTH_ADDRESS_LENGTH * 2)
{
if (((ch >= '0') && (ch <= '9')))
- {
temp[count++] = ch - '0';
- }
else if (((ch >= 'a') && (ch <= 'z')))
- {
temp[count++] = ch - 'a' + 10;
- }
else if (((ch >= 'A') && (ch <= 'Z')))
- {
temp[count++] = ch - 'A' + 10;
- }
}
for (; i < BLUETOOTH_ADDRESS_LENGTH; i++)
bool net_nfc_util_strip_string(char *buffer, int buffer_length)
{
- bool result = false;
- char *temp = NULL;
int i = 0;
+ char *temp = NULL;
+ bool result = false;
_net_nfc_util_alloc_mem(temp, buffer_length);
- if (temp == NULL)
- {
+ if (NULL == temp)
return result;
- }
for (; i < buffer_length; i++)
{
{
memcpy(temp, &buffer[i], buffer_length - i);
memset(buffer, 0x00, buffer_length);
-
memcpy(buffer, temp, buffer_length - i);
result = true;
{
ch = (ch ^ (uint8_t)((*lpwCrc) & 0x00FF));
ch = (ch ^ (ch << 4));
- *lpwCrc = (*lpwCrc >> 8) ^ ((uint16_t)ch << 8) ^ ((uint16_t)ch << 3) ^ ((uint16_t)ch >> 4);
+ *lpwCrc = (*lpwCrc >> 8) ^ ((uint16_t)ch << 8) ^
+ ((uint16_t)ch << 3) ^ ((uint16_t)ch >> 4);
return (*lpwCrc);
}
-void net_nfc_util_compute_CRC(CRC_type_e CRC_type, uint8_t *buffer, uint32_t length)
+void net_nfc_util_compute_CRC(CRC_type_e CRC_type, uint8_t *buffer,
+ uint32_t length)
{
uint8_t chBlock = 0;
- int msg_length = length - 2;
uint8_t *temp = buffer;
+ int msg_length = length - 2;
// default is CRC_B
uint16_t wCrc = 0xFFFF; /* ISO/IEC 13239 (formerly ISO/IEC 3309) */
break;
}
- do
- {
+ do{
chBlock = *buffer++;
_net_nfc_util_update_CRC(chBlock, &wCrc);
- }
- while (--msg_length > 0);
+ } while (--msg_length > 0);
- if (CRC_type == CRC_B)
- {
+ if (CRC_B == CRC_type)
wCrc = ~wCrc; /* ISO/IEC 13239 (formerly ISO/IEC 3309) */
- }
temp[length - 2] = (uint8_t)(wCrc & 0xFF);
temp[length - 1] = (uint8_t)((wCrc >> 8) & 0xFF);
const char *net_nfc_util_get_schema_string(int index)
{
- if (index == 0 || index >= NET_NFC_SCHEMA_MAX)
- return NULL;
- else
- return schema[index];
+ RETV_IF(0 == index, NULL);
+ RETV_IF(index >= NET_NFC_SCHEMA_MAX, NULL);
+
+ return schema[index];
}
void net_nfc_util_gdbus_variant_to_buffer(GVariant *variant, uint8_t **buffer,
size_t *length)
{
+ guint size = 0;
GVariantIter *iter;
guint8 *buf = NULL;
- guint size = 0;
- if (variant == NULL)
- return;
+ RET_IF(NULL == variant);
g_variant_get(variant, "a(y)", &iter);
size = g_variant_iter_n_children(iter);
buf = g_new0(guint8, size);
+
if (buf != NULL)
{
- guint8 element;
guint i;
+ guint8 element;
i = 0;
while (g_variant_iter_loop(iter, "(y)", &element))
data_s *net_nfc_util_gdbus_variant_to_data(GVariant *variant)
{
+ guint size = 0;
GVariantIter *iter;
guint8 *buf = NULL;
- guint size = 0;
data_s *result = NULL;
- if (variant == NULL)
- return result;
+ RETV_IF(NULL == variant, result);
g_variant_get(variant, "a(y)", &iter);
void net_nfc_util_gdbus_variant_to_data_s(GVariant *variant, data_s *data)
{
- GVariantIter *iter;
-
+ guint size = 0;
guint8 element;
+ GVariantIter *iter;
guint8 *buf = NULL;
- guint size = 0;
-
- if (data == NULL)
- return;
+ RET_IF(NULL == data);
+ RET_IF(NULL == variant);
data->buffer = NULL;
data->length = 0;
- if (variant == NULL)
- {
- return;
- }
-
g_variant_get(variant, "a(y)", &iter);
size = g_variant_iter_n_children(iter);
buf = g_new0(guint8, size);
+
if (buf != NULL)
{
guint i = 0;
g_variant_builder_init(&builder, G_VARIANT_TYPE("a(y)"));
- if (buffer && length > 0)
+ if (NULL == buffer || length <= 0)
{
int i;
GVariant *net_nfc_util_gdbus_data_to_variant(const data_s *data)
{
if (data != NULL)
- {
- return net_nfc_util_gdbus_buffer_to_variant(data->buffer,
- data->length);
- }
+ return net_nfc_util_gdbus_buffer_to_variant(data->buffer, data->length);
else
- {
return net_nfc_util_gdbus_buffer_to_variant(NULL, 0);
- }
}
ndef_message_s *net_nfc_util_gdbus_variant_to_ndef_message(GVariant *variant)
{
- ndef_message_s *message = NULL;
data_s data = { NULL, 0 };
+ ndef_message_s *temp = NULL;
+ ndef_message_s *message = NULL;
- if (variant == NULL)
- return NULL;
+ RETV_IF(NULL == variant, NULL);
net_nfc_util_gdbus_variant_to_data_s(variant, &data);
- if (data.buffer && data.length > 0)
- {
- ndef_message_s *temp = NULL;
-
- if (net_nfc_util_create_ndef_message(&temp) == NET_NFC_OK) {
- if (net_nfc_util_convert_rawdata_to_ndef_message(
- &data, temp) == NET_NFC_OK) {
- message = temp;
- } else {
- NFC_ERR("net_nfc_create_ndef_message_from_rawdata failed");
+ if (NULL == data.buffer || data.length <= 0)
+ return NULL;
- net_nfc_util_free_ndef_message(temp);
- }
- } else {
- NFC_ERR("net_nfc_util_create_ndef_message failed");
+ if (net_nfc_util_create_ndef_message(&temp) == NET_NFC_OK)
+ {
+ if (net_nfc_util_convert_rawdata_to_ndef_message(&data, temp) == NET_NFC_OK)
+ {
+ message = temp;
}
+ else
+ {
+ NFC_ERR("net_nfc_create_ndef_message_from_rawdata failed");
- net_nfc_util_free_data(&data);
+ net_nfc_util_free_ndef_message(temp);
+ }
+ }
+ else
+ {
+ NFC_ERR("net_nfc_util_create_ndef_message failed");
}
+ net_nfc_util_free_data(&data);
+
return message;
}
+
GVariant *net_nfc_util_gdbus_ndef_message_to_variant(
const ndef_message_s *message)
{
- GVariant *variant = NULL;
- data_s *data = NULL;
size_t length;
+ net_nfc_error_e ret;
+ data_s *data = NULL;
+ GVariant *variant = NULL;
- length = net_nfc_util_get_ndef_message_length(
- (ndef_message_s *)message);
- if (length > 0) {
+ length = net_nfc_util_get_ndef_message_length((ndef_message_s *)message);
+ if (length > 0)
+ {
data_s temp = { NULL, 0 };
- if (net_nfc_util_alloc_data(&temp, length) == true) {
- if (net_nfc_util_convert_ndef_message_to_rawdata(
- (ndef_message_s *)message,
- &temp) == NET_NFC_OK) {
+ if (net_nfc_util_alloc_data(&temp, length) == true)
+ {
+ ret = net_nfc_util_convert_ndef_message_to_rawdata((ndef_message_s *)message,
+ &temp);
+ if (NET_NFC_OK == ret)
+ {
data = &temp;
- } else {
+ }
+ else
+ {
NFC_ERR("can not convert ndef_message to rawdata");
net_nfc_util_free_data(&temp);
}
- } else {
+ }
+ else
+ {
NFC_ERR("net_nfc_util_alloc_data failed");
}
- } else {
+ }
+ else
+ {
NFC_ERR("message length is 0");
}
int i;
unsigned char tmp_char;
- for (i=0;i<size/2;i++) {
+ for ( i = 0; i < size/2; i++)
+ {
tmp_char = array[i];
array[i] = array[size-1-i];
array[size-1-i] = tmp_char;
const net_nfc_carrier_property_s *arg2 = key2;
if (arg1->attribute < arg2->attribute)
- {
return -1;
- }
else if (arg1->attribute > arg2->attribute)
- {
return 1;
- }
else
- {
return 0;
- }
}
-static net_nfc_carrier_property_s *__find_property_by_attrubute(GList *list, uint16_t attribute)
+static net_nfc_carrier_property_s *__find_property_by_attrubute(GList *list,
+ uint16_t attribute)
{
GList *found = NULL;
net_nfc_carrier_property_s temp;
temp.attribute = attribute;
found = g_list_find_custom(list, &temp, __property_equal_to);
- if (found == NULL)
- {
+ if (NULL == found)
return NULL;
- }
return (net_nfc_carrier_property_s *)found->data;
}
static void __find_nth_group(gpointer data, gpointer user_data)
{
- net_nfc_carrier_property_s *info = data;
search_index *nth = user_data;
+ net_nfc_carrier_property_s *info = data;
- if (info == NULL || user_data == NULL)
- return;
+ RET_IF(NULL == info);
+ RET_IF(NULL == user_data);
if (info->is_group)
{
if (nth->current == nth->target)
- {
nth->found = data;
- }
+
nth->current++;
}
}
{
net_nfc_carrier_property_s *info = data;
- if (info == NULL)
- return;
+ RET_IF(NULL == info);
if (info->is_group)
{
}
else
{
- NFC_DBG("FREE: element is found ATTRIB:0x%X length:%d", info->attribute, info->length);
+ NFC_DBG("FREE: element is found ATTRIB:0x%X length:%d",
+ info->attribute, info->length);
_net_nfc_util_free_mem(info->data);
_net_nfc_util_free_mem(info);
}
}
-static net_nfc_error_e __net_nfc_util_create_connection_handover_collsion_resolution_record(ndef_record_s **record)
+static net_nfc_error_e
+ __net_nfc_util_create_connection_handover_collsion_resolution_record(
+ ndef_record_s **record)
{
+
uint32_t state = 0;
- data_s typeName = { 0 };
+ uint16_t random_num;
data_s payload = { 0 };
+ data_s typeName = { 0 };
uint8_t rand_buffer[2] = { 0, 0 };
- uint16_t random_num;
- if (record == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
state = (uint32_t)time(NULL);
random_num = (unsigned short)rand_r(&state);
payload.buffer = rand_buffer;
payload.length = 2;
- NFC_DBG("rand number = [0x%x] [0x%x] => [0x%x]", payload.buffer[0], payload.buffer[1], random_num);
+ NFC_DBG("rand number = [0x%x] [0x%x] => [0x%x]",
+ payload.buffer[0], payload.buffer[1], random_num);
- return net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &typeName, NULL, &payload, record);
+ return net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE,
+ &typeName, NULL, &payload, record);
}
static int __net_nfc_get_size_of_attribute(int attribute)
}
}
-net_nfc_error_e net_nfc_util_create_carrier_config(net_nfc_carrier_config_s **config, net_nfc_conn_handover_carrier_type_e type)
+net_nfc_error_e net_nfc_util_create_carrier_config(
+ net_nfc_carrier_config_s **config, net_nfc_conn_handover_carrier_type_e type)
{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (type < 0 || type >= NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN)
- {
- return NET_NFC_OUT_OF_BOUND;
- }
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
+ RETV_IF(type < 0, NET_NFC_OUT_OF_BOUND);
+ RETV_IF(type >= NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN, NET_NFC_OUT_OF_BOUND);
_net_nfc_util_alloc_mem(*config, sizeof(net_nfc_carrier_config_s));
- if (*config == NULL)
- {
+ if (NULL == *config)
return NET_NFC_ALLOC_FAIL;
- }
(*config)->type = type;
(*config)->length = 0;
NFC_DBG("ADD property: [ATTRIB:0x%X, SIZE:%d]", attribute, size);
- if (config == NULL || data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
if (__find_property_by_attrubute(config->data, attribute) != NULL)
- {
return NET_NFC_ALREADY_REGISTERED;
- }
_net_nfc_util_alloc_mem(elem, sizeof (net_nfc_carrier_property_s));
- if (elem == NULL)
- {
+ if (NULL == elem)
return NET_NFC_ALLOC_FAIL;
- }
+
elem->attribute = attribute;
elem->length = size;
elem->is_group = false;
_net_nfc_util_alloc_mem(elem->data, size);
- if (elem->data == NULL)
+ if (NULL == elem->data)
{
_net_nfc_util_free_mem(elem);
return NET_NFC_ALLOC_FAIL;
{
net_nfc_carrier_property_s *elem = NULL;
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
elem = __find_property_by_attrubute(config->data, attribute);
- if (elem == NULL)
- {
+ if (NULL == elem)
return NET_NFC_NO_DATA_FOUND;
- }
config->data = g_list_remove(config->data, elem);
config->length -= (elem->length + 2 * __net_nfc_get_size_of_attribute(attribute));
{
net_nfc_carrier_property_s *elem = NULL;
- if (config == NULL || size == NULL || data == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == size, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
elem = __find_property_by_attrubute(config->data, attribute);
- if (elem == NULL)
+ if (NULL == elem)
{
*size = 0;
*data = NULL;
net_nfc_error_e net_nfc_util_append_carrier_config_group(
net_nfc_carrier_config_s *config, net_nfc_carrier_property_s *group)
{
- if (config == NULL || group == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
if (g_list_find(config->data, group) != NULL)
return NET_NFC_ALREADY_REGISTERED;
net_nfc_error_e net_nfc_util_remove_carrier_config_group(
net_nfc_carrier_config_s *config, net_nfc_carrier_property_s *group)
{
- if (config == NULL || group == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
if (g_list_find(config->data, group) != NULL)
- {
return NET_NFC_NO_DATA_FOUND;
- }
config->length -= group->length;
config->data = g_list_remove(config->data, group);
{
search_index result;
- if (config == NULL || group == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (index < 0)
- {
- return NET_NFC_OUT_OF_BOUND;
- }
+ RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
+ RETV_IF(index < 0, NET_NFC_OUT_OF_BOUND);
result.current = 0;
result.target = index;
g_list_foreach(config->data, __find_nth_group, &result);
- if (result.found == NULL)
- {
+ if (NULL == result.found)
return NET_NFC_NO_DATA_FOUND;
- }
+
*group = (net_nfc_carrier_property_s *)result.found;
return NET_NFC_OK;
net_nfc_error_e net_nfc_util_free_carrier_config(net_nfc_carrier_config_s *config)
{
- if (config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
g_list_foreach(config->data, __free_all_data, NULL);
g_list_free(config->data);
net_nfc_error_e net_nfc_util_create_carrier_config_group(
net_nfc_carrier_property_s **group, uint16_t attribute)
{
- if (group == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
_net_nfc_util_alloc_mem(*group, sizeof(net_nfc_carrier_property_s));
- if (*group == NULL)
- {
+ if (NULL == *group)
return NET_NFC_ALLOC_FAIL;
- }
(*group)->attribute = attribute;
(*group)->is_group = true;
NFC_DBG("ADD group property: [ATTRIB:0x%X, SIZE:%d]", attribute, size);
- if (group == NULL || data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
if (__find_property_by_attrubute((GList *)group->data, attribute) != NULL)
- {
return NET_NFC_ALREADY_REGISTERED;
- }
_net_nfc_util_alloc_mem(elem, sizeof (net_nfc_carrier_property_s));
- if (elem == NULL)
- {
+ if (NULL == elem)
return NET_NFC_ALLOC_FAIL;
- }
+
elem->attribute = attribute;
elem->length = size;
elem->is_group = false;
_net_nfc_util_alloc_mem(elem->data, size);
- if (elem->data == NULL)
+ if (NULL == elem->data)
{
_net_nfc_util_free_mem(elem);
return NET_NFC_ALLOC_FAIL;
{
net_nfc_carrier_property_s *elem = NULL;
- if (group == NULL || size == NULL || data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == size, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
elem = __find_property_by_attrubute((GList*)(group->data), attribute);
- if (elem == NULL)
+ if (NULL == elem)
{
*size = 0;
*data = NULL;
{
net_nfc_carrier_property_s *elem = NULL;
- if (group == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
elem = __find_property_by_attrubute((GList*)(group->data), attribute);
- if (elem == NULL)
- {
+ if (NULL == elem)
return NET_NFC_NO_DATA_FOUND;
- }
+
group->length -= elem->length;
group->data = g_list_remove((GList*)(group->data), elem);
net_nfc_error_e net_nfc_util_free_carrier_group(net_nfc_carrier_property_s *group)
{
- if (group == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == group, NET_NFC_NULL_PARAMETER);
+
g_list_foreach((GList*)(group->data), __free_all_data, NULL);
g_list_free((GList*)(group->data));
static void __make_serial_wifi(gpointer data, gpointer user_data)
{
- net_nfc_carrier_property_s *info = data;
- data_s *payload = user_data;
- uint8_t *current;
int inc = 0;
+ uint8_t *current;
+ data_s *payload = user_data;
+ net_nfc_carrier_property_s *info = data;
- if (info == NULL || user_data == NULL)
- return;
+ RET_IF(NULL == info);
+ RET_IF(NULL == user_data);
current = payload->buffer + payload->length;
inc = __net_nfc_get_size_of_attribute(info->attribute);
}
else
{
- NFC_DBG("[WIFI]Element is found attrib:0x%X length:%d current:%d", info->attribute, info->length, payload->length);
+ NFC_DBG("[WIFI]Element is found attrib:0x%X length:%d current:%d",
+ info->attribute, info->length, payload->length);
*(uint16_t *)current = info->attribute;
net_nfc_convert_byte_order(current,2);
*(uint16_t *)(current + inc) = info->length;
static void __make_serial_bt(gpointer data, gpointer user_data)
{
- net_nfc_carrier_property_s *info = data;
- data_s *payload = user_data;
- uint8_t *current;
int inc = 0;
+ uint8_t *current;
+ data_s *payload = user_data;
+ net_nfc_carrier_property_s *info = data;
- if (info == NULL || user_data == NULL)
- return;
+ RET_IF(NULL == info);
+ RET_IF(NULL == user_data);
current = payload->buffer + payload->length; /* payload->length is zero */
{
if (info->attribute != NET_NFC_BT_ATTRIBUTE_ADDRESS)
{
- NFC_DBG("[BT]Element is found attrib:0x%X length:%d current:%d", info->attribute, info->length, payload->length);
+ NFC_DBG("[BT]Element is found attrib:0x%X length:%d current:%d",
+ info->attribute, info->length, payload->length);
inc = __net_nfc_get_size_of_attribute(info->attribute);
*current = info->length + 1;
*(current + inc) = info->attribute;
data_s payload = { NULL, 0 };
data_s record_type = { NULL, 0 };
- if (record == NULL || config == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
_net_nfc_util_alloc_mem(payload.buffer, config->length);
- if (payload.buffer == NULL)
- {
+ if (NULL == payload.buffer)
return NET_NFC_ALLOC_FAIL;
- }
+
payload.length = 0; /* this should be zero because this will be used as current position of data written */
- if (config->type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)
+ if (NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS == config->type)
{
record_type.buffer = (uint8_t *)CONN_HANDOVER_WIFI_BSS_CARRIER_MIME_NAME;
record_type.length = strlen(CONN_HANDOVER_WIFI_BSS_CARRIER_MIME_NAME);
g_list_foreach(config->data, __make_serial_wifi, &payload);
}
- else if (config->type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_IBSS)
+ else if (NET_NFC_CONN_HANDOVER_CARRIER_WIFI_IBSS == config->type)
{
record_type.buffer = (uint8_t *)CONN_HANDOVER_WIFI_IBSS_CARRIER_MIME_NAME;
record_type.length = strlen(CONN_HANDOVER_WIFI_IBSS_CARRIER_MIME_NAME);
g_list_foreach(config->data, __make_serial_wifi, &payload);
}
- else if (config->type == NET_NFC_CONN_HANDOVER_CARRIER_BT)
+ else if (NET_NFC_CONN_HANDOVER_CARRIER_BT == config->type)
{
record_type.buffer = (uint8_t *)CONN_HANDOVER_BT_CARRIER_MIME_NAME;
record_type.length = strlen(CONN_HANDOVER_BT_CARRIER_MIME_NAME);
NFC_DBG("payload length = %d", payload.length);
- return net_nfc_util_create_record(NET_NFC_RECORD_MIME_TYPE, &record_type, NULL, &payload, record);
+ return net_nfc_util_create_record(NET_NFC_RECORD_MIME_TYPE, &record_type, NULL,
+ &payload, record);
}
-static net_nfc_error_e __net_nfc_get_list_from_serial_for_wifi(GList **list, uint8_t *data, uint32_t length)
+static net_nfc_error_e __net_nfc_get_list_from_serial_for_wifi(
+ GList **list, uint8_t *data, uint32_t length)
{
uint8_t *current = data;
uint8_t *last = current + length;
{
net_nfc_carrier_property_s *elem = NULL;
_net_nfc_util_alloc_mem(elem, sizeof(net_nfc_carrier_property_s));
- if (elem == NULL)
- {
+ if (NULL == elem)
return NET_NFC_ALLOC_FAIL;
- }
+
elem->attribute = current[0]<<8|current[1];
elem->length = current[2]<<8|current[3];
else
{
_net_nfc_util_alloc_mem(elem->data, elem->length);
- if (elem->data == NULL)
+ if (NULL == elem->data)
{
_net_nfc_util_free_mem(elem);
return NET_NFC_ALLOC_FAIL;
net_nfc_error_e __net_nfc_get_list_from_serial_for_bt(GList **list, uint8_t *data, uint32_t length)
{
- net_nfc_carrier_property_s *elem = NULL;
- uint8_t *current = data;
uint8_t *last = NULL;
+ uint8_t *current = data;
+ net_nfc_carrier_property_s *elem = NULL;
current += 2; /* remove oob data length two bytes length*/
length -= 2;
_net_nfc_util_alloc_mem(elem, sizeof(net_nfc_carrier_property_s));
- if (elem == NULL)
- {
+ if (NULL == elem)
return NET_NFC_ALLOC_FAIL;
- }
+
elem->attribute = (uint16_t)NET_NFC_BT_ATTRIBUTE_ADDRESS;
elem->length = 6; /* BT address length is always 6 */
_net_nfc_util_alloc_mem(elem->data, elem->length);
- if (elem->data == NULL)
+ if (NULL == elem->data)
{
_net_nfc_util_free_mem(elem);
return NET_NFC_ALLOC_FAIL;
while (current < last)
{
_net_nfc_util_alloc_mem(elem, sizeof(net_nfc_carrier_property_s));
- if (elem == NULL)
- {
+ if (NULL == elem)
return NET_NFC_ALLOC_FAIL;
- }
+
elem->length = *((uint8_t *)current) - 1;
elem->attribute = *((uint8_t *)(++current));
_net_nfc_util_alloc_mem(elem->data, elem->length);
- if (elem->data == NULL)
+ if (NULL == elem->data)
{
_net_nfc_util_free_mem(elem);
return NET_NFC_ALLOC_FAIL;
net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
data_s *rawdata, ndef_message_s *ndef)
{
- ndef_record_s *newRec = NULL;
- ndef_record_s *prevRec = NULL;
- uint8_t *current = NULL;
uint8_t *last = NULL;
+ uint8_t *current = NULL;
uint8_t ndef_header = 0;
+ ndef_record_s *newRec = NULL;
+ ndef_record_s *prevRec = NULL;
net_nfc_error_e result = NET_NFC_OK;
- if (rawdata == NULL || ndef == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == ndef, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
+ RETV_IF(rawdata->length < 3, NET_NFC_INVALID_FORMAT);
current = rawdata->buffer;
last = current + rawdata->length;
- if(rawdata->length < 3)
- return NET_NFC_INVALID_FORMAT;
-
for(ndef->recordCount = 0; current < last; ndef->recordCount++)
{
ndef_header = *current++;
}
_net_nfc_util_alloc_mem(newRec, sizeof(ndef_record_s));
- if (newRec == NULL)
+ if (NULL == newRec)
{
result = NET_NFC_ALLOC_FAIL;
goto error;
/* ndef header set */
if (ndef_header & NET_NFC_NDEF_RECORD_MASK_MB)
- {
newRec->MB = 1;
- }
+
if (ndef_header & NET_NFC_NDEF_RECORD_MASK_ME)
- {
newRec->ME = 1;
- }
+
if (ndef_header & NET_NFC_NDEF_RECORD_MASK_CF)
- {
newRec->CF = 1;
- }
+
if (ndef_header & NET_NFC_NDEF_RECORD_MASK_SR)
- {
newRec->SR = 1;
- }
+
if (ndef_header & NET_NFC_NDEF_RECORD_MASK_IL)
- {
newRec->IL = 1;
- }
newRec->TNF = ndef_header & NET_NFC_NDEF_RECORD_MASK_TNF;
/* ID length check */
if(ndef_header & NET_NFC_NDEF_RECORD_MASK_IL)
- {
newRec->id_s.length = *current++;
- }
else
- {
newRec->id_s.length = 0;
- }
/* to do : chunked record */
-
/* empty record check */
if((ndef_header & NET_NFC_NDEF_RECORD_MASK_TNF) == NET_NFC_NDEF_TNF_EMPTY)
{
- if(newRec->type_s.length != 0 || newRec->id_s.length != 0 || newRec->payload_s.length != 0)
+ if(newRec->type_s.length != 0 || newRec->id_s.length != 0
+ || newRec->payload_s.length != 0)
{
result = NET_NFC_INVALID_FORMAT;
goto error;
if(newRec->type_s.length > 0)
{
_net_nfc_util_alloc_mem(newRec->type_s.buffer, newRec->type_s.length);
- if (newRec->type_s.buffer == NULL)
+ if (NULL == newRec->type_s.buffer)
{
result = NET_NFC_ALLOC_FAIL;
goto error;
if(newRec->id_s.length > 0)
{
_net_nfc_util_alloc_mem(newRec->id_s.buffer, newRec->id_s.length);
- if (newRec->id_s.buffer == NULL)
+ if (NULL == newRec->id_s.buffer)
{
result = NET_NFC_ALLOC_FAIL;
goto error;
net_nfc_error_e net_nfc_util_free_record(ndef_record_s *record)
{
- if (record == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
if (record->type_s.buffer != NULL)
_net_nfc_util_free_mem(record->type_s.buffer);
{
ndef_record_s *record_temp = NULL;
- if (typeName == NULL || payload == NULL || record == NULL)
- return NET_NFC_NULL_PARAMETER;
+ RETV_IF(NULL == typeName, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == payload, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
- if (recordType < NET_NFC_RECORD_EMPTY || recordType > NET_NFC_RECORD_UNCHAGNED)
- return NET_NFC_OUT_OF_BOUND;
+ RETV_IF(recordType < NET_NFC_RECORD_EMPTY, NET_NFC_OUT_OF_BOUND);
+ RETV_IF(recordType > NET_NFC_RECORD_UNCHAGNED, NET_NFC_OUT_OF_BOUND);
/* empty_tag */
- if (recordType == NET_NFC_RECORD_EMPTY)
+ if (NET_NFC_RECORD_EMPTY == recordType)
{
if ((typeName->buffer != NULL) || (payload->buffer != NULL)
|| (id->buffer != NULL) || (typeName->length != 0) || (payload->length != 0)
}
_net_nfc_util_alloc_mem(record_temp, sizeof(ndef_record_s));
- if (record_temp == NULL)
+ if (NULL == record_temp)
return NET_NFC_ALLOC_FAIL;
// set type name and length and TNF field
if(record_temp->type_s.length > 0)
{
_net_nfc_util_alloc_mem(record_temp->type_s.buffer, record_temp->type_s.length);
- if (record_temp->type_s.buffer == NULL)
+ if (NULL == record_temp->type_s.buffer)
{
_net_nfc_util_free_mem(record_temp);
record_temp->payload_s.length = payload->length;
if(payload->length >0)
{
- _net_nfc_util_alloc_mem(record_temp->payload_s.buffer, record_temp->payload_s.length);
- if (record_temp->payload_s.buffer == NULL)
+ _net_nfc_util_alloc_mem(record_temp->payload_s.buffer,
+ record_temp->payload_s.length);
+
+ if (NULL == record_temp->payload_s.buffer)
{
_net_nfc_util_free_mem(record_temp->type_s.buffer);
_net_nfc_util_free_mem(record_temp);
return NET_NFC_ALLOC_FAIL;
}
- memcpy(record_temp->payload_s.buffer, payload->buffer, record_temp->payload_s.length);
+ memcpy(record_temp->payload_s.buffer, payload->buffer,
+ record_temp->payload_s.length);
}
else
{
}
if (payload->length < 256)
- {
record_temp->SR = 1;
- }
else
- {
record_temp->SR = 0;
- }
// set id and id length and IL field
if (id != NULL && id->buffer != NULL && id->length > 0)
{
record_temp->id_s.length = id->length;
_net_nfc_util_alloc_mem(record_temp->id_s.buffer, record_temp->id_s.length);
- if (record_temp->id_s.buffer == NULL)
+ if (NULL == record_temp->id_s.buffer)
{
_net_nfc_util_free_mem(record_temp->payload_s.buffer);
_net_nfc_util_free_mem(record_temp->type_s.buffer);
return NET_NFC_OK;
}
-net_nfc_error_e net_nfc_util_create_uri_type_record(const char *uri, net_nfc_schema_type_e protocol_schema, ndef_record_s **record)
+net_nfc_error_e net_nfc_util_create_uri_type_record(const char *uri,
+ net_nfc_schema_type_e protocol_schema, ndef_record_s **record)
{
- net_nfc_error_e error;
data_s type_data;
+ net_nfc_error_e error;
data_s payload_data = { NULL, 0 };
- if (uri == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == uri, NET_NFC_NULL_PARAMETER);
payload_data.length = strlen((char *)uri) + 1;
- if (payload_data.length == 1)
- {
- return NET_NFC_INVALID_PARAM;
- }
+
+ RETV_IF(1 == payload_data.length, NET_NFC_INVALID_PARAM);
_net_nfc_util_alloc_mem(payload_data.buffer, payload_data.length);
- if (payload_data.buffer == NULL)
- {
+ if (NULL == payload_data.buffer)
return NET_NFC_ALLOC_FAIL;
- }
payload_data.buffer[0] = protocol_schema; /* first byte of payload is protocol scheme */
memcpy(payload_data.buffer + 1, uri, payload_data.length - 1);
type_data.length = 1;
type_data.buffer = (uint8_t *)URI_RECORD_TYPE;
- error = net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type_data, NULL, &payload_data, record);
+ error = net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE,
+ &type_data, NULL, &payload_data, record);
_net_nfc_util_free_mem(payload_data.buffer);
return error;
}
-net_nfc_error_e net_nfc_util_create_text_type_record(const char *text, const char *lang_code_str, net_nfc_encode_type_e encode, ndef_record_s **record)
+net_nfc_error_e net_nfc_util_create_text_type_record(const char *text,
+ const char *lang_code_str, net_nfc_encode_type_e encode, ndef_record_s **record)
{
+ int offset = 0;
data_s type_data;
- data_s payload_data;
int controll_byte;
- int offset = 0;
+ data_s payload_data;
- if (text == NULL || lang_code_str == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == text, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == lang_code_str, NET_NFC_NULL_PARAMETER);
- if ((encode < NET_NFC_ENCODE_UTF_8 || encode > NET_NFC_ENCODE_UTF_16))
- {
- return NET_NFC_OUT_OF_BOUND;
- }
+ RETVM_IF(encode < NET_NFC_ENCODE_UTF_8 || NET_NFC_ENCODE_UTF_16 < encode ,
+ NET_NFC_OUT_OF_BOUND, "encode(%d) is invalid", encode);
payload_data.length = strlen((char *)text) + strlen(lang_code_str) + 1;
_net_nfc_util_alloc_mem(payload_data.buffer, payload_data.length);
- if (payload_data.buffer == NULL)
+ if (NULL == payload_data.buffer)
{
return NET_NFC_ALLOC_FAIL;
}
controll_byte = strlen(lang_code_str) & 0x3F;
- if (encode == NET_NFC_ENCODE_UTF_16)
+ if (NET_NFC_ENCODE_UTF_16 == encode)
{
controll_byte = controll_byte | 0x80;
}
type_data.length = 1;
type_data.buffer = (uint8_t *)TEXT_RECORD_TYPE;
- net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type_data, NULL, &payload_data, record);
+ net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type_data, NULL,
+ &payload_data, record);
_net_nfc_util_free_mem(payload_data.buffer);
return NET_NFC_OK;
}
-net_nfc_error_e net_nfc_util_set_record_id(ndef_record_s *record, uint8_t *data, int length)
+net_nfc_error_e net_nfc_util_set_record_id(ndef_record_s *record,
+ uint8_t *data, int length)
{
- if (record == NULL || data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (length < 1)
- {
- return NET_NFC_OUT_OF_BOUND;
- }
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
+ RETV_IF(length < 1, NET_NFC_OUT_OF_BOUND);
if (record->id_s.buffer != NULL && record->id_s.length > 0)
- {
_net_nfc_util_free_mem(record->id_s.buffer);
- }
_net_nfc_util_alloc_mem(record->id_s.buffer, length);
+
if (record->id_s.buffer == NULL)
- {
return NET_NFC_ALLOC_FAIL;
- }
+
memcpy(record->id_s.buffer, data, length);
record->id_s.length = length;
record->IL = 1;
{
uint32_t RecordLength = 1;
- if (Record == NULL)
- return 0;
+ RETV_IF(NULL == Record, 0);
/* Type length is present only for following TNF
NET_NFC_TNF_NFCWELLKNOWN
/* for non empty record */
if (Record->TNF != NET_NFC_NDEF_TNF_EMPTY)
- {
RecordLength += Record->payload_s.length;
- }
/* ID and IDlength are present only if IL flag is set*/
if (Record->IL != 0)
return RecordLength;
}
-net_nfc_error_e net_nfc_util_create_uri_string_from_uri_record(ndef_record_s *record, char **uri)
+net_nfc_error_e net_nfc_util_create_uri_string_from_uri_record(
+ ndef_record_s *record, char **uri)
{
net_nfc_error_e result = NET_NFC_OK;
- if (record == NULL || uri == NULL)
- {
- return NET_NFC_INVALID_PARAM;
- }
+ RETV_IF(NULL == uri, NET_NFC_INVALID_PARAM);
+ RETV_IF(NULL == record, NET_NFC_INVALID_PARAM);
*uri = NULL;
- if (record->TNF == NET_NFC_RECORD_WELL_KNOWN_TYPE &&
+ if (NET_NFC_RECORD_WELL_KNOWN_TYPE == record->TNF &&
(record->type_s.length == 1 && record->type_s.buffer[0] == 'U'))
{
data_s *payload = &record->payload_s;
/* buffer length include a schema byte.
* so it does not need to allocate one more byte for string. */
if ((scheme = net_nfc_util_get_schema_string(payload->buffer[0])) != NULL)
- {
length = strlen(scheme);
- }
*uri = (char *)calloc(1, length + payload->length);
if (*uri != NULL)
NFC_ERR("invalid payload in record");
}
}
- else if (record->TNF == NET_NFC_RECORD_URI)
+ else if (NET_NFC_RECORD_URI == record->TNF)
{
data_s *type = &record->type_s;
*uri = (char *)calloc(1, type->length + 1);
if (*uri != NULL)
- {
memcpy(*uri, type->buffer, type->length);
- }
else
- {
result = NET_NFC_ALLOC_FAIL;
- }
}
}
else
// return x509;
//}
-static X509 *_load_certificate_from_mem(int format, uint8_t *buffer, uint32_t length, char *password)
+static X509 *_load_certificate_from_mem(int format, uint8_t *buffer,
+ uint32_t length, char *password)
{
X509 *x509 = NULL;
BIO *mem = NULL;
{
result->store = X509_STORE_new();
if (result->store != NULL)
- {
OpenSSL_add_all_algorithms();
- }
else
- {
NFC_ERR("X509_STORE_new failed");
- }
}
else
{
return result;
}
-void net_nfc_util_openssl_release_verify_certificate(net_nfc_openssl_verify_context_s *context)
+void net_nfc_util_openssl_release_verify_certificate(
+ net_nfc_openssl_verify_context_s *context)
{
if (context != NULL)
{
}
}
-bool net_nfc_util_openssl_add_certificate_of_signer(net_nfc_openssl_verify_context_s *context, uint8_t *buffer, uint32_t length)
+bool net_nfc_util_openssl_add_certificate_of_signer(
+ net_nfc_openssl_verify_context_s *context, uint8_t *buffer, uint32_t length)
{
bool result = false;
return result;
}
-bool net_nfc_util_openssl_add_certificate_of_ca(net_nfc_openssl_verify_context_s *context, uint8_t *buffer, uint32_t length)
+bool net_nfc_util_openssl_add_certificate_of_ca(
+ net_nfc_openssl_verify_context_s *context, uint8_t *buffer, uint32_t length)
{
- bool result = false;
X509 *x509 = NULL;
+ bool result = false;
x509 = _load_certificate_from_mem(1, buffer, length, NULL);
if (x509 != NULL)
{
if (X509_STORE_add_cert(context->store, x509))
- {
result = true;
- }
}
return result;
}
-int net_nfc_util_openssl_verify_certificate(net_nfc_openssl_verify_context_s *context)
+int net_nfc_util_openssl_verify_certificate(
+ net_nfc_openssl_verify_context_s *context)
{
int result = 0;
X509_STORE_CTX *store_ctx = NULL;
{
X509_STORE_set_flags(context->store, 0);
if (X509_STORE_CTX_init(store_ctx, context->store, context->signer_cert, 0) == true)
- {
result = X509_verify_cert(store_ctx);
- }
else
- {
NFC_ERR("X509_STORE_CTX_init failed");
- }
X509_STORE_CTX_free(store_ctx);
}
if ((p12 = d2i_PKCS12_bio(in, NULL)) != NULL)
{
if (PKCS12_verify_mac(p12, password, strlen(password)) == true)
- {
ret = PKCS12_parse(p12, password, pkey, cert, ca);
- }
else
- {
NFC_ERR("Mac verify error (wrong password?) in PKCS12 file");
- }
PKCS12_free(p12);
}
BIO *key = NULL;
EVP_PKEY *pkey = NULL;
- if (file == NULL)
+ if (NULL == file)
{
NFC_ERR("no keyfile specified\n");
return pkey;
}
- if (format == OPENSSL_FORMAT_ENGINE)
+ if (OPENSSL_FORMAT_ENGINE == format)
{
if (e != NULL)
{
pkey = ENGINE_load_private_key(e, file, NULL/*ui_method*/, (void *)pass);
if (!pkey)
- {
NFC_ERR("cannot load key from engine");
- }
}
else
{
break;
case OPENSSL_FORMAT_PEM :
- pkey = PEM_read_bio_PrivateKey(key, NULL, (pem_password_cb *)_password_callback, (void *)pass);
+ pkey = PEM_read_bio_PrivateKey(key, NULL,
+ (pem_password_cb *)_password_callback, (void *)pass);
break;
case OPENSSL_FORMAT_PKCS12 :
if (_load_pkcs12(key, pass, &pkey, NULL, NULL) == false)
- {
NFC_ERR("_load_pkcs12 failed");
- }
break;
case OPENSSL_FORMAT_MSBLOB :
break;
case OPENSSL_FORMAT_PVK :
- pkey = b2i_PVK_bio(key, (pem_password_cb *)_password_callback, (void *)pass);
+ pkey = b2i_PVK_bio(key, (pem_password_cb *)_password_callback,
+ (void *)pass);
break;
default :
return pkey;
}
-EVP_PKEY *_load_pubkey(const char *file, int format, const char *pass, ENGINE *e, const char *key_descrip)
+EVP_PKEY *_load_pubkey(const char *file, int format,
+ const char *pass, ENGINE *e, const char *key_descrip)
{
BIO *key = NULL;
EVP_PKEY *pkey = NULL;
- if (file == NULL)
+ if (NULL == file)
{
NFC_ERR("no keyfile specified");
return pkey;
}
- if (format == OPENSSL_FORMAT_ENGINE)
+ if (OPENSSL_FORMAT_ENGINE == format)
{
if (e != NULL)
- {
pkey = ENGINE_load_public_key(e, file, NULL/*ui_method*/, (void *)pass);
- }
else
- {
NFC_ERR("no engine specified");
- }
}
else
{
case OPENSSL_FORMAT_PEMRSA :
{
RSA *rsa;
- rsa = PEM_read_bio_RSAPublicKey(key, NULL, (pem_password_cb *)_password_callback, (void *)pass);
+ rsa = PEM_read_bio_RSAPublicKey(key, NULL,
+ (pem_password_cb *)_password_callback, (void *)pass);
if (rsa)
{
pkey = EVP_PKEY_new();
break;
case OPENSSL_FORMAT_PEM :
- pkey = PEM_read_bio_PUBKEY(key, NULL, (pem_password_cb *)_password_callback, (void *)pass);
+ pkey = PEM_read_bio_PUBKEY(key, NULL,
+ (pem_password_cb *)_password_callback, (void *)pass);
break;
case OPENSSL_FORMAT_MSBLOB :
return pkey;
}
-int net_nfc_util_openssl_sign_buffer(uint32_t type, uint8_t *buffer, uint32_t length, char *key_file, char *password, uint8_t *sign, uint32_t *sign_len)
+int net_nfc_util_openssl_sign_buffer(uint32_t type, uint8_t *buffer,
+ uint32_t length, char *key_file, char *password, uint8_t *sign, uint32_t *sign_len)
{
+ EVP_PKEY *pkey;
+ ENGINE *engine;
int result = 0;
const EVP_MD *md = NULL;
- ENGINE *engine;
- EVP_PKEY *pkey;
OpenSSL_add_all_algorithms();
return result;
}
-int net_nfc_util_openssl_verify_signature(uint32_t type, uint8_t *buffer, uint32_t length, uint8_t *cert, uint32_t cert_len, uint8_t *sign, uint32_t sign_len)
+int net_nfc_util_openssl_verify_signature(uint32_t type, uint8_t *buffer,
+ uint32_t length, uint8_t *cert, uint32_t cert_len, uint8_t *sign, uint32_t sign_len)
{
+ EVP_PKEY *pkey;
int result = 0;
- const EVP_MD *md = NULL;
ENGINE *engine;
- EVP_PKEY *pkey;
+ const EVP_MD *md = NULL;
OpenSSL_add_all_algorithms();
#endif
/* TODO : DER?? PEM?? */
-int net_nfc_util_get_cert_list_from_file(char *file_name, char *password, uint8_t **buffer, uint32_t *length, uint32_t *cert_count)
+int net_nfc_util_get_cert_list_from_file(char *file_name, char *password,
+ uint8_t **buffer, uint32_t *length, uint32_t *cert_count)
{
int result = 0;
BIO *bio = NULL;
if (_load_pkcs12(bio, password, &pkey, &x509, &ca) != 0)
{
- X509 *temp_x509;
int i;
+ int32_t ret = 0;
+ X509 *temp_x509;
+ uint32_t count = 0;
+ uint32_t offset = 0;
uint32_t temp_len = 0;
uint8_t *temp_buf = NULL;
- uint32_t offset = 0;
- uint32_t count = 0;
- int32_t ret = 0;
if ((ret = i2d_X509(x509, NULL)) > 0)
{
return result;
}
-bool net_nfc_util_openssl_encode_base64(const uint8_t *buffer, const uint32_t buf_len, char *result, uint32_t max_len, bool new_line_char)
+bool net_nfc_util_openssl_encode_base64(const uint8_t *buffer,
+ const uint32_t buf_len, char *result, uint32_t max_len, bool new_line_char)
{
- bool ret = false;
BUF_MEM *bptr;
BIO *b64, *bmem;
+ bool ret = false;
- if (buffer == NULL || buf_len == 0)
- {
- return ret;
- }
+ RETV_IF(0 == buf_len, ret);
+ RETV_IF(NULL == buffer, ret);
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new(BIO_s_mem());
- if (new_line_char == false)
+ if (false == new_line_char)
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
b64 = BIO_push(b64, bmem);
return ret;
}
-bool net_nfc_util_openssl_decode_base64(const char *buffer, uint8_t *result, uint32_t *out_len, bool new_line_char)
+bool net_nfc_util_openssl_decode_base64(const char *buffer, uint8_t *result,
+ uint32_t *out_len, bool new_line_char)
{
+ char *temp;
bool ret = false;
unsigned int length = 0;
- char *temp;
- if (buffer == NULL || (length = strlen(buffer)) == 0)
- {
- return ret;
- }
+ RETV_IF(NULL == buffer, ret);
+ RETV_IF((length = strlen(buffer)) == 0, ret);
_net_nfc_util_alloc_mem(temp, length);
if (temp != NULL)
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new_mem_buf((void *)buffer, length);
- if (new_line_char == false)
+ if (false == new_line_char)
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
bmem = BIO_push(b64, bmem);
return ret;
}
-bool net_nfc_util_openssl_digest(const char *algorithm, const uint8_t *buffer, const uint32_t buf_len, uint8_t *result, uint32_t *out_len)
+bool net_nfc_util_openssl_digest(const char *algorithm, const uint8_t *buffer,
+ const uint32_t buf_len, uint8_t *result, uint32_t *out_len)
{
const EVP_MD *md;
- unsigned char *temp;
bool ret = false;
+ unsigned char *temp;
- if (algorithm == NULL || buffer == NULL || buf_len == 0)
- {
- return ret;
- }
+ RETV_IF(0 == buf_len, ret);
+ RETV_IF(buffer == NULL, ret);
+ RETV_IF(algorithm == NULL, ret);
OpenSSL_add_all_digests();
EVP_DigestInit(&mdCtx, md);
if (EVP_DigestUpdate(&mdCtx, buffer, buf_len) != 0)
- {
NFC_ERR("EVP_DigestUpdate failed");
- }
+
EVP_DigestFinal(&mdCtx, temp, &resultLen);
if (*out_len >= resultLen)
#define __NEXT_SUB_FIELD(__dst) ((__dst)->value + (__dst)->length)
-bool _get_records_data_buffer(ndef_record_s *begin_record, ndef_record_s *end_record, uint8_t **buffer, uint32_t *length)
+bool _get_records_data_buffer(ndef_record_s *begin_record,
+ ndef_record_s *end_record, uint8_t **buffer, uint32_t *length)
{
- bool result = false;
uint32_t len = 0;
+ bool result = false;
ndef_record_s *current_record = NULL;
- if (begin_record == NULL || begin_record == end_record)
- return result;
+ RETV_IF(NULL == begin_record, result);
+ RETV_IF(begin_record == end_record, result);
/* count total buffer length */
current_record = begin_record;
len += current_record->id_s.length;
/* payload length */
- if (current_record->payload_s.buffer != NULL && current_record->payload_s.length > 0)
+ if (current_record->payload_s.buffer != NULL &&
+ current_record->payload_s.length > 0)
+ {
len += current_record->payload_s.length;
+ }
current_record = current_record->next;
}
while (offset < len && current_record != NULL && current_record != end_record)
{
/* type length */
- if (current_record->type_s.buffer != NULL && current_record->type_s.length > 0)
+ if (current_record->type_s.buffer != NULL &&
+ current_record->type_s.length > 0)
{
- memcpy(buf + offset, current_record->type_s.buffer, MIN(current_record->type_s.length, len - offset));
+ memcpy(buf + offset, current_record->type_s.buffer,
+ MIN(current_record->type_s.length, len - offset));
offset += MIN(current_record->type_s.length, len - offset);
}
/* ID length */
if (current_record->id_s.buffer != NULL && current_record->id_s.length > 0)
{
- memcpy(buf + offset, current_record->id_s.buffer, MIN(current_record->id_s.length, len - offset));
+ memcpy(buf + offset, current_record->id_s.buffer,
+ MIN(current_record->id_s.length, len - offset));
offset += MIN(current_record->id_s.length, len - offset);
}
/* payload length */
- if (current_record->payload_s.buffer != NULL && current_record->payload_s.length > 0)
+ if (current_record->payload_s.buffer != NULL &&
+ current_record->payload_s.length > 0)
{
- memcpy(buf + offset, current_record->payload_s.buffer, MIN(current_record->payload_s.length, len - offset));
+ memcpy(buf + offset, current_record->payload_s.buffer,
+ MIN(current_record->payload_s.length, len - offset));
offset += MIN(current_record->payload_s.length, len - offset);
}
return result;
}
-net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_record, ndef_record_s *sign_record)
+net_nfc_error_e net_nfc_util_verify_signature_records(ndef_record_s *begin_record,
+ ndef_record_s *sign_record)
{
- net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
- uint8_t *buffer = NULL;
+ int ret;
uint32_t length = 0;
+ uint8_t *buffer = NULL;
+ net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
- if (begin_record == NULL || sign_record == NULL || begin_record == sign_record)
- return NET_NFC_INVALID_PARAM;
+ RETV_IF(NULL == sign_record, NET_NFC_INVALID_PARAM);
+ RETV_IF(NULL == begin_record, NET_NFC_INVALID_PARAM);
+ RETV_IF(begin_record == sign_record, NET_NFC_INVALID_PARAM);
/* get signed data */
if (_get_records_data_buffer(begin_record, sign_record, &buffer, &length) == true)
NFC_DBG("signature type : %d", sign_info->sign_type);
NFC_DBG("signature length : %d", sign_info->signature.length);
- if (sign_info->uri_present == true)
+ if (true == sign_info->uri_present)
{
/* TODO */
/* receive the signature data directed by uri */
}
/* parse certificate chain info */
- chain_info = (net_nfc_certificate_chain_s *)__NEXT_SUB_FIELD(&(sign_info->signature));
+ chain_info =
+ (net_nfc_certificate_chain_s *)__NEXT_SUB_FIELD(&(sign_info->signature));
- SECURE_LOGD("certificate URI present? : %s", chain_info->uri_present ? "true" : "false");
+ SECURE_LOGD("certificate URI present? : %s",
+ chain_info->uri_present ? "true" : "false");
NFC_DBG("certificate format : %d", chain_info->cert_format);
NFC_DBG("number of certificates : %d", chain_info->num_of_certs);
/* the first certificate is signer's one
* verify signature of content */
- if (net_nfc_util_openssl_verify_signature(sign_info->sign_type, buffer, length, data_info->value, data_info->length, sign_info->signature.value, sign_info->signature.length) == true)
+ ret = net_nfc_util_openssl_verify_signature(sign_info->sign_type,
+ buffer,
+ length,
+ data_info->value,
+ data_info->length,
+ sign_info->signature.value,
+ sign_info->signature.length);
+
+ if (true == ret)
{
if (chain_info->num_of_certs > 1)
{
context = net_nfc_util_openssl_init_verify_certificate();
/* add signer's certificate */
- net_nfc_util_openssl_add_certificate_of_signer(context, data_info->value, data_info->length);
+ net_nfc_util_openssl_add_certificate_of_signer(context, data_info->value,
+ data_info->length);
/* verify certificate using certificate chain */
for (i = 1, data_info = (net_nfc_sub_field_s *)__NEXT_SUB_FIELD(data_info);
NFC_DBG("certficate length : %d", data_info->length);
//DEBUG_MSG_PRINT_BUFFER(data_info->value, data_info->length);
- net_nfc_util_openssl_add_certificate_of_ca(context, data_info->value, data_info->length);
+ net_nfc_util_openssl_add_certificate_of_ca(context, data_info->value,
+ data_info->length);
}
/* if the CA_Uri is present, continue adding certificate from uri */
- if (chain_info->uri_present == true)
+ if (true == chain_info->uri_present)
{
/* TODO : Need to implement */
NFC_ERR("NOT IMPLEMENTED (found_root == false && chain_info->uri_present == true)");
else
{
if(buffer != NULL)
- {
_net_nfc_util_free_mem(buffer);
- }
+
NFC_ERR("_get_records_data_buffer failed");
}
net_nfc_error_e net_nfc_util_verify_signature_ndef_message(ndef_message_s *msg)
{
- net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
ndef_record_s *begin_record = NULL;
ndef_record_s *current_record = NULL;
+ net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
+
begin_record = msg->records;
current_record = msg->records;
while (current_record != NULL)
{
- if (begin_record == NULL)
- {
+ if (NULL == begin_record)
begin_record = current_record;
- }
if (IS_EMPTY_RECORD(current_record))
{
/*
* sign method
*/
-net_nfc_error_e net_nfc_util_sign_records(ndef_message_s *msg, int begin_index, int end_index, char *cert_file, char *password)
+net_nfc_error_e net_nfc_util_sign_records(ndef_message_s *msg, int begin_index,
+ int end_index, char *cert_file, char *password)
{
- net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
- ndef_record_s *begin_record = NULL, *end_record = NULL, *record = NULL;
- data_s payload = { NULL, 0 };
- uint8_t *data_buffer = NULL;
+ uint32_t cert_len = 0;
uint32_t data_len = 0;
+ uint32_t cert_count = 0;
+ uint8_t *data_buffer = NULL;
+ uint8_t *cert_buffer = NULL;
+ data_s payload = { NULL, 0 };
uint8_t signature[1024] = { 0, };
uint32_t sign_len = sizeof(signature);
- uint8_t *cert_buffer = NULL;
- uint32_t cert_len = 0;
- uint32_t cert_count = 0;
+ net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
+ ndef_record_s *begin_record = NULL, *end_record = NULL, *record = NULL;
+
net_nfc_util_get_record_by_index(msg, begin_index, &begin_record);
net_nfc_util_get_record_by_index(msg, end_index, &end_record);
- NFC_DBG("total record count : %d, begin_index : %d, end_index : %d", msg->recordCount, begin_index, end_index);
+ NFC_DBG("total record count : %d, begin_index : %d, end_index : %d", msg->recordCount,
+ begin_index, end_index);
/* get target data */
_get_records_data_buffer(begin_record, end_record->next, &data_buffer, &data_len);
DEBUG_MSG_PRINT_BUFFER(data_buffer, data_len);
- net_nfc_util_openssl_sign_buffer(NET_NFC_SIGN_TYPE_PKCS_1, data_buffer, data_len, cert_file, password, signature, &sign_len);
+ net_nfc_util_openssl_sign_buffer(NET_NFC_SIGN_TYPE_PKCS_1, data_buffer, data_len,
+ cert_file, password, signature, &sign_len);
/* get cert chain */
- net_nfc_util_get_cert_list_from_file(cert_file, password, &cert_buffer, &cert_len, &cert_count);
+ net_nfc_util_get_cert_list_from_file(cert_file, password, &cert_buffer, &cert_len,
+ &cert_count);
/* create payload */
- payload.length = sizeof(net_nfc_signature_record_s) + sign_len + sizeof(net_nfc_certificate_chain_s) + cert_len;
+ payload.length = sizeof(net_nfc_signature_record_s) + sign_len +
+ sizeof(net_nfc_certificate_chain_s) + cert_len;
_net_nfc_util_alloc_mem(payload.buffer, payload.length);
- net_nfc_signature_record_s *sign_record = (net_nfc_signature_record_s *)payload.buffer;
+ net_nfc_signature_record_s *sign_record =
+ (net_nfc_signature_record_s *)payload.buffer;
sign_record->version = 1;
sign_record->uri_present = 0;
sign_record->sign_type = NET_NFC_SIGN_TYPE_PKCS_1;
__FILL_SUB_FIELD(&(sign_record->signature), signature, sign_len);
}
- net_nfc_certificate_chain_s *chain = (net_nfc_certificate_chain_s *)__NEXT_SUB_FIELD(&(sign_record->signature));
+ net_nfc_certificate_chain_s *chain =
+ (net_nfc_certificate_chain_s *)__NEXT_SUB_FIELD(&(sign_record->signature));
+
if (cert_count < 16)
- {
chain->uri_present = 0;
- }
else
- {
chain->uri_present = 1;
- }
chain->cert_format = NET_NFC_CERT_FORMAT_X_509;
chain->num_of_certs = cert_count;
/* create record */
data_s type = { (uint8_t *)"Sig", 3 };
- net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type, NULL, &payload, &record);
+ net_nfc_util_create_record(NET_NFC_RECORD_WELL_KNOWN_TYPE, &type, NULL,
+ &payload, &record);
/* get last record index */
net_nfc_util_append_record_by_index(msg, end_index + 1, record);
return result;
}
-net_nfc_error_e net_nfc_util_sign_ndef_message(ndef_message_s *msg, char *cert_file, char *password)
+net_nfc_error_e net_nfc_util_sign_ndef_message(ndef_message_s *msg,
+ char *cert_file, char *password)
{
net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
pid_t net_nfc_server_gdbus_get_pid(const char *name)
{
+ GVariant *_ret;
guint pid = 0;
GError *error = NULL;
- GVariant *_ret;
_ret = g_dbus_connection_call_sync(connection,
"org.freedesktop.DBus",
-1,
NULL,
&error);
- if (_ret != NULL) {
+
+ if (_ret != NULL)
+ {
g_variant_get(_ret, "(u)", &pid);
g_variant_unref(_ret);
}
const gchar *name, const gchar *old_owner,
const gchar *new_owner, void *user_data)
{
- if (name == NULL || old_owner == NULL || new_owner == NULL) {
- NFC_ERR("invalid parameter");
+ RET_IF(NULL == name);
+ RET_IF(NULL == old_owner);
+ RET_IF(NULL == new_owner);
- return;
- }
-
- if (strlen(new_owner) == 0) {
- if (net_nfc_server_gdbus_check_client_is_running(old_owner)) {
+ if (strlen(new_owner) == 0)
+ {
+ if (net_nfc_server_gdbus_check_client_is_running(old_owner))
+ {
/* unregister service */
net_nfc_server_llcp_unregister_services(old_owner);
}
static void _on_name_owner_changed(GDBusConnection *connection,
- const gchar *sender_name, const gchar *object_path,
- const gchar *interface_name, const gchar *signal_name,
- GVariant *parameters, gpointer user_data)
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
{
gchar *name;
gchar *old_owner;
gchar *new_owner;
- g_variant_get(parameters,
- "(sss)",
- &name,
- &old_owner,
- &new_owner);
+ g_variant_get(parameters, "(sss)", &name, &old_owner, &new_owner);
- _name_owner_changed((GDBusProxy *)connection,
- name, old_owner, new_owner, user_data);
+ _name_owner_changed((GDBusProxy *)connection, name, old_owner, new_owner, user_data);
}
static void _subscribe_name_owner_changed_event()
{
- if (connection == NULL)
- return;
+ RET_IF(NULL == connection);
/* subscribe signal */
subscribe_id = g_dbus_connection_signal_subscribe(connection,
static void _unsubscribe_name_owner_changed_event()
{
- if (connection == NULL)
- return;
+ RET_IF(NULL == connection);
/* subscribe signal */
- if (subscribe_id > 0) {
+ if (subscribe_id > 0)
g_dbus_connection_signal_unsubscribe(connection, subscribe_id);
- }
}
static void net_nfc_server_gdbus_init(void)
g_object_unref(connection);
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (connection == NULL)
+ if (NULL == connection)
{
NFC_ERR("Can not get connection %s", error->message);
g_error_free (error);
if (net_nfc_server_p2p_init(connection) == FALSE)
{
- NFC_ERR("Can not init tag");
+ NFC_ERR("Can not init p2p");
return;
}
if (net_nfc_server_handover_init(connection) == FALSE)
{
- NFC_ERR("Can not initialize transceive");
+ NFC_ERR("Can not initialize handover");
return;
}
if (net_nfc_server_se_init(connection) == FALSE)
{
- NFC_ERR("Can not init Test");
+ NFC_ERR("Can not init se");
return;
}
if (net_nfc_server_snep_init(connection) == FALSE)
{
- NFC_ERR("Can not init controller thread");
+ NFC_ERR("Can not init snep");
return;
}
if (net_nfc_server_system_handler_init(connection) == FALSE)
{
- NFC_ERR("Can not init controller thread");
+ NFC_ERR("Can not init system handler");
return;
}
int main(int argc, char *argv[])
{
-
- void *handle = NULL;
guint id = 0;
+ void *handle = NULL;
+ GError *error = NULL;
gboolean use_daemon = FALSE;
GOptionContext *option_context;
- GError *error = NULL;
net_nfc_change_log_tag();
net_nfc_app_util_clean_storage(MESSAGE_STORAGE);
handle = net_nfc_controller_onload();
- if (handle == NULL)
+ if (NULL == handle)
{
NFC_ERR("load plugin library is failed");
gpointer data;
};
-static gpointer controller_thread_func(gpointer user_data);
-
-static void controller_async_queue_free_func(gpointer user_data);
-
-static void controller_thread_deinit_thread_func(gpointer user_data);
-
-static void controller_target_detected_cb(void *info,
- void *user_context);
-
-static void controller_se_transaction_cb(void *info,
- void *user_context);
-
-static void controller_llcp_event_cb(void *info,
- void *user_context);
-
-static void controller_init_thread_func(gpointer user_data);
-
-#ifndef ESE_ALWAYS_ON
-static void controller_deinit_thread_func(gpointer user_data);
-#endif
-
-static void restart_polling_loop_thread_func(gpointer user_data);
-
static GAsyncQueue *controller_async_queue = NULL;
static GThread *controller_thread = NULL;
static gpointer controller_thread_func(gpointer user_data)
{
- if (controller_async_queue == NULL)
+ if (NULL == controller_async_queue)
{
g_thread_exit(NULL);
return NULL;
static void controller_target_detected_cb(void *info,
void *user_context)
{
- net_nfc_request_target_detected_t *req =
- (net_nfc_request_target_detected_t *)info;
+ net_nfc_request_target_detected_t *req = (net_nfc_request_target_detected_t *)info;
g_assert(info != NULL);
{
net_nfc_server_set_target_info(info);
- if (req->devType != NET_NFC_UNKNOWN_TARGET) {
+ if (req->devType != NET_NFC_UNKNOWN_TARGET)
+ {
if (req->devType == NET_NFC_NFCIP1_TARGET ||
- req->devType == NET_NFC_NFCIP1_INITIATOR) {
+ req->devType == NET_NFC_NFCIP1_INITIATOR)
+ {
/* llcp target detected */
net_nfc_server_llcp_target_detected(info);
- } else {
+ }
+ else
+ {
/* tag target detected */
net_nfc_server_tag_target_detected(info);
}
static void _controller_llcp_event_cb(gpointer user_data)
{
- net_nfc_request_llcp_msg_t *req_msg =
- (net_nfc_request_llcp_msg_t *)user_data;
+ net_nfc_request_llcp_msg_t *req_msg = (net_nfc_request_llcp_msg_t *)user_data;
- if (req_msg == NULL)
- {
- NFC_ERR("can not get llcp_event info");
-
- return;
- }
+ RET_IF(NULL == req_msg);
switch (req_msg->request_type)
{
case NET_NFC_MESSAGE_SERVICE_LLCP_SOCKET_ERROR:
case NET_NFC_MESSAGE_SERVICE_LLCP_SOCKET_ACCEPTED_ERROR:
- net_nfc_controller_llcp_socket_error_cb(
- req_msg->llcp_socket,
- req_msg->result,
- NULL,
- (void *)req_msg->user_param);
+ net_nfc_controller_llcp_socket_error_cb(req_msg->llcp_socket,
+ req_msg->result, NULL, (void *)req_msg->user_param);
break;
case NET_NFC_MESSAGE_SERVICE_LLCP_SEND:
case NET_NFC_MESSAGE_SERVICE_LLCP_SEND_TO:
- net_nfc_controller_llcp_sent_cb(
- req_msg->llcp_socket,
- req_msg->result,
- NULL,
- (void *)req_msg->user_param);
+ net_nfc_controller_llcp_sent_cb(req_msg->llcp_socket,
+ req_msg->result, NULL, (void *)req_msg->user_param);
break;
case NET_NFC_MESSAGE_SERVICE_LLCP_RECEIVE:
data_s data = { msg->data.buffer, msg->data.length };
net_nfc_controller_llcp_received_cb(msg->client_socket,
- msg->result,
- &data,
- (void *)req_msg->user_param);
+ msg->result, &data, (void *)req_msg->user_param);
}
break;
/* FIXME : pass sap */
net_nfc_controller_llcp_received_cb(msg->client_socket,
- msg->result,
- &data,
- (void *)req_msg->user_param);
+ msg->result, &data, (void *)req_msg->user_param);
}
break;
case NET_NFC_MESSAGE_SERVICE_LLCP_CONNECT:
case NET_NFC_MESSAGE_SERVICE_LLCP_CONNECT_SAP:
- net_nfc_controller_llcp_connected_cb(
- req_msg->llcp_socket,
- req_msg->result,
- NULL,
- (void *)req_msg->user_param);
+ net_nfc_controller_llcp_connected_cb(req_msg->llcp_socket,
+ req_msg->result, NULL, (void *)req_msg->user_param);
break;
case NET_NFC_MESSAGE_SERVICE_LLCP_DISCONNECT:
- net_nfc_controller_llcp_disconnected_cb(
- req_msg->llcp_socket,
- req_msg->result,
- NULL,
- (void *)req_msg->user_param);
+ net_nfc_controller_llcp_disconnected_cb(req_msg->llcp_socket,
+ req_msg->result, NULL, (void *)req_msg->user_param);
break;
default:
NFC_INFO("net_nfc_contorller_register_listener success");
result = net_nfc_server_llcp_set_config(NULL);
+
if (result != NET_NFC_OK)
- {
- NFC_ERR("net_nfc_server_llcp_set config failed, [%d]",
- result);
- }
+ NFC_ERR("net_nfc_server_llcp_set config failed, [%d]", result);
NFC_INFO("net_nfc_server_llcp_set_config success");
}
net_nfc_error_e result;
if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG,
- NET_NFC_ALL_DISABLE,
- &result) == false) {
-
+ NET_NFC_ALL_DISABLE, &result) == false)
+ {
NFC_ERR("net_nfc_controller_configure_discovery failed, [%d]", result);
}
static void restart_polling_loop_thread_func(gpointer user_data)
{
-
gint state = 0;
gint pm_state = 0;
-
net_nfc_error_e result;
if (vconf_get_bool(VCONFKEY_NFC_STATE, &state) != 0)
if (pm_state == VCONFKEY_PM_STATE_NORMAL)
{
- if (net_nfc_controller_configure_discovery(
- NET_NFC_DISCOVERY_MODE_CONFIG,
- NET_NFC_ALL_ENABLE,
- &result) == true)
+ if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG,
+ NET_NFC_ALL_ENABLE, &result) == true)
{
NFC_DBG("polling enable");
}
if (pm_state == VCONFKEY_PM_STATE_LCDOFF)
{
- if (net_nfc_controller_configure_discovery(
- NET_NFC_DISCOVERY_MODE_CONFIG,
- NET_NFC_ALL_DISABLE,
- &result) == true)
+ if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_CONFIG,
+ NET_NFC_ALL_DISABLE, &result) == true)
{
NFC_DBG("polling disabled");
}
{
GError *error = NULL;
- controller_async_queue = g_async_queue_new_full(
- controller_async_queue_free_func);
+ controller_async_queue = g_async_queue_new_full(controller_async_queue_free_func);
- controller_thread = g_thread_try_new("controller_thread",
- controller_thread_func,
- NULL,
- &error);
+ controller_thread = g_thread_try_new("controller_thread", controller_thread_func,
+ NULL, &error);
- if (controller_thread == NULL)
+ if (NULL == controller_thread)
{
- NFC_ERR("can not create controller thread: %s",
- error->message);
+ NFC_ERR("can not create controller thread: %s", error->message);
g_error_free(error);
return FALSE;
}
void net_nfc_server_controller_thread_deinit(void)
{
- if(net_nfc_server_controller_async_queue_push(
- controller_thread_deinit_thread_func,
+ if(net_nfc_server_controller_async_queue_push(controller_thread_deinit_thread_func,
NULL)==FALSE)
{
NFC_ERR("Failed to push onto the queue");
void net_nfc_server_controller_init(void)
{
- if(net_nfc_server_controller_async_queue_push(
- controller_init_thread_func,
+ if(net_nfc_server_controller_async_queue_push(controller_init_thread_func,
NULL)==FALSE)
{
NFC_ERR("Failed to push onto the queue");
#endif
gboolean net_nfc_server_controller_async_queue_push(
- net_nfc_server_controller_func func,
- gpointer user_data)
+ net_nfc_server_controller_func func, gpointer user_data)
{
ControllerFuncData *func_data;
- if(controller_async_queue == NULL)
+ if(NULL == controller_async_queue)
{
NFC_ERR("controller_async_queue is not initialized");
void net_nfc_server_restart_polling_loop(void)
{
- if(net_nfc_server_controller_async_queue_push(
- restart_polling_loop_thread_func,
+ if(net_nfc_server_controller_async_queue_push(restart_polling_loop_thread_func,
NULL) == FALSE)
{
NFC_ERR("Failed to push onto the queue");
/* TODO */
bool net_nfc_server_gdbus_check_privilege(GDBusMethodInvocation *invocation,
- GVariant *privilege,
- const char *object,
- const char *right)
+ GVariant *privilege, const char *object, const char *right)
{
#ifdef SECURITY_SERVER
- data_s priv = { NULL, 0 };
int result;
+ data_s priv = { NULL, 0 };
- if (privilege == NULL || object == NULL || right == NULL) {
- return false;
- }
+ RETV_IF(NULL == right, false);
+ RETV_IF(NULL == object, false);
+ RETV_IF(NULL == privilege, false);
net_nfc_util_gdbus_variant_to_data_s(privilege, &priv);
- result = security_server_check_privilege_by_cookie((char *)priv.buffer,
- object, right);
+ result = security_server_check_privilege_by_cookie((char *)priv.buffer, object, right);
net_nfc_util_free_data(&priv);
- if (result < 0) {
+ if (result < 0)
+ {
NFC_ERR("permission denied : \"%s\", \"%s\"", object, right);
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Privilege",
#endif
const char *id = g_dbus_method_invocation_get_sender(invocation);
- net_nfc_server_gdbus_add_client_context(id,
- NET_NFC_CLIENT_ACTIVE_STATE);
+ net_nfc_server_gdbus_add_client_context(id, NET_NFC_CLIENT_ACTIVE_STATE);
return true;
}
info->launch_popup_state = NET_NFC_LAUNCH_APP_SELECT;
info->launch_popup_state_no_check = NET_NFC_LAUNCH_APP_SELECT;
- g_hash_table_insert(client_contexts,
- (gpointer)info->id,
- (gpointer)info);
+ g_hash_table_insert(client_contexts, (gpointer)info->id, (gpointer)info);
NFC_DBG("current client count = [%d]",
net_nfc_server_gdbus_get_client_count_no_lock());
}
void net_nfc_server_gdbus_for_each_client_context(
- net_nfc_server_gdbus_for_each_client_cb cb,
- void *user_param)
+ net_nfc_server_gdbus_for_each_client_cb cb, void *user_param)
{
- GHashTableIter iter;
char *id;
+ GHashTableIter iter;
net_nfc_client_context_info_t *info;
- if (cb == NULL)
- return;
+ RET_IF(NULL == cb);
pthread_mutex_lock(&context_lock);
g_hash_table_iter_init(&iter, client_contexts);
- while (g_hash_table_iter_next(&iter, (gpointer *)&id,
- (gpointer *)&info) == true) {
+
+ while (g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&info) == true)
+ {
cb(info, user_param);
}
pthread_mutex_lock(&context_lock);
info = net_nfc_server_gdbus_get_client_context_no_lock(id);
- if (info != NULL) {
+ if (info != NULL)
state = info->state;
- }
pthread_mutex_unlock(&context_lock);
pthread_mutex_lock(&context_lock);
info = net_nfc_server_gdbus_get_client_context_no_lock(id);
- if (info != NULL) {
+ if (info != NULL)
info->state = state;
- }
pthread_mutex_unlock(&context_lock);
}
pthread_mutex_lock(&context_lock);
info = net_nfc_server_gdbus_get_client_context_no_lock(id);
- if (info != NULL) {
- if (check_foreground == CHECK_FOREGROUND) {
+ if (info != NULL)
+ {
+ if (check_foreground == CHECK_FOREGROUND)
info->launch_popup_state = popup_state;
- } else {
+ else
info->launch_popup_state_no_check = popup_state;
- }
}
pthread_mutex_unlock(&context_lock);
pthread_mutex_lock(&context_lock);
info = net_nfc_server_gdbus_get_client_context_no_lock(id);
- if (info != NULL) {
- if (info->launch_popup_state_no_check ==
- NET_NFC_NO_LAUNCH_APP_SELECT) {
+ if (info != NULL)
+ {
+ if (info->launch_popup_state_no_check == NET_NFC_NO_LAUNCH_APP_SELECT)
result = NET_NFC_NO_LAUNCH_APP_SELECT;
- } else {
+ else
result = info->launch_popup_state;
- }
}
pthread_mutex_unlock(&context_lock);
net_nfc_launch_popup_state_e net_nfc_server_gdbus_get_client_popup_state(
pid_t pid)
{
- GHashTableIter iter;
char *id;
- net_nfc_launch_popup_state_e state = NET_NFC_LAUNCH_APP_SELECT;
+ GHashTableIter iter;
net_nfc_client_context_info_t *info = NULL, *temp;
+ net_nfc_launch_popup_state_e state = NET_NFC_LAUNCH_APP_SELECT;
pthread_mutex_lock(&context_lock);
g_hash_table_iter_init(&iter, client_contexts);
- while (g_hash_table_iter_next(&iter, (gpointer *)&id,
- (gpointer *)&temp) == true) {
- if (temp->launch_popup_state_no_check ==
- NET_NFC_NO_LAUNCH_APP_SELECT) {
+ while (g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&temp) == true)
+ {
+ if (NET_NFC_NO_LAUNCH_APP_SELECT == temp->launch_popup_state_no_check)
+ {
state = NET_NFC_NO_LAUNCH_APP_SELECT;
break;
}
- if (temp->pgid == pid) {
+ if (pid == temp->pgid)
+ {
info = temp;
break;
}
}
- if (info != NULL) {
+ if (info != NULL)
state = info->launch_popup_state;
- }
pthread_mutex_unlock(&context_lock);
pthread_mutex_lock(&context_lock);
info = net_nfc_server_gdbus_get_client_context_no_lock(id);
- if (info != NULL) {
+ if (info != NULL)
info->ref_se++;
- }
pthread_mutex_unlock(&context_lock);
}
pthread_mutex_lock(&context_lock);
info = net_nfc_server_gdbus_get_client_context_no_lock(id);
- if (info != NULL) {
+ if (info != NULL)
info->ref_se--;
- }
pthread_mutex_unlock(&context_lock);
}
pthread_mutex_lock(&context_lock);
- if (g_hash_table_size(client_contexts) > 0) {
- GHashTableIter iter;
+ if (g_hash_table_size(client_contexts) > 0)
+ {
char *id;
+ GHashTableIter iter;
net_nfc_client_context_info_t *info;
g_hash_table_iter_init(&iter, client_contexts);
- while (g_hash_table_iter_next(&iter, (gpointer *)&id,
- (gpointer *)&info) == true) {
- if (info->ref_se > 0) {
+ while (g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&info) == true)
+ {
+ if (info->ref_se > 0)
+ {
result = true;
break;
}
static net_nfc_oem_interface_s g_interface;
-static void *net_nfc_controller_load_file(const char *dir_path,
- const char *filename)
+static void *net_nfc_controller_load_file(const char *dir_path, const char *filename)
{
- void *handle = NULL;
- char path[PATH_MAX] = { '\0' };
struct stat st;
-
+ void *handle = NULL;
net_nfc_error_e result;
+ char path[PATH_MAX] = { '\0' };
bool (*onload)(net_nfc_oem_interface_s *interfaces);
snprintf(path, PATH_MAX, "%s/%s", dir_path, filename);
NFC_DBG("path : %s", path);
- if (stat(path, &st) == -1) {
+ if (stat(path, &st) == -1)
+ {
NFC_ERR("stat failed : file not found");
goto ERROR;
}
- if (S_ISREG(st.st_mode) == 0) {
+ if (S_ISREG(st.st_mode) == 0)
+ {
NFC_ERR("S_ISREG(st.st_mode) == 0");
goto ERROR;
}
handle = dlopen(path, RTLD_LAZY);
- if (handle == NULL) {
+ if (NULL == handle)
+ {
char buffer[1024];
NFC_ERR("dlopen failed, [%d] : %s",
errno, strerror_r(errno, buffer, sizeof(buffer)));
}
onload = dlsym(handle, "onload");
- if (onload == NULL) {
+ if (NULL == onload)
+ {
char buffer[1024];
NFC_ERR("dlsym failed, [%d] : %s",
errno, strerror_r(errno, buffer, sizeof(buffer)));
}
memset(&g_interface, 0, sizeof(g_interface));
- if (onload(&g_interface) == false) {
+ if (onload(&g_interface) == false)
+ {
NFC_ERR("onload failed");
goto ERROR;
}
- if (net_nfc_controller_support_nfc(&result) == false) {
- NFC_ERR("net_nfc_controller_support_nfc failed, [%d]",
- result);
+ if (net_nfc_controller_support_nfc(&result) == false)
+ {
+ NFC_ERR("net_nfc_controller_support_nfc failed, [%d]", result);
goto ERROR;
}
return handle;
ERROR :
- if (handle != NULL) {
+ if (handle != NULL)
dlclose(handle);
- }
return NULL;
}
void *handle = NULL;
dirp = opendir(NFC_MANAGER_MODULEDIR);
- if (dirp == NULL)
+ if (NULL == dirp)
{
NFC_ERR("Can not open directory %s", NFC_MANAGER_MODULEDIR);
return NULL;
while ((dir = readdir(dirp)))
{
- if ((strcmp(dir->d_name, ".") == 0) ||
- (strcmp(dir->d_name, "..") == 0))
- {
+ if ((strcmp(dir->d_name, ".") == 0) || (strcmp(dir->d_name, "..") == 0))
continue;
- }
/* check ".so" suffix */
if (strcmp(dir->d_name + (strlen(dir->d_name) - strlen(".so")), ".so") != 0)
closedir(dirp);
/* load default plugin */
- handle = net_nfc_controller_load_file(NFC_MANAGER_MODULEDIR,
- NET_NFC_DEFAULT_PLUGIN);
+ handle = net_nfc_controller_load_file(NFC_MANAGER_MODULEDIR, NET_NFC_DEFAULT_PLUGIN);
if (handle)
{
static socket_info_t* _get_socket_info(net_nfc_llcp_socket_t socket)
{
- socket_info_t *result;
GSList *item;
+ socket_info_t *result;
item = g_slist_find_custom(llcp_sockets, GUINT_TO_POINTER(socket),
_compare_socket_info);
- if (item != NULL) {
+ if (item != NULL)
result = (socket_info_t *)item->data;
- } else {
+ else
result = NULL;
- }
return result;
}
socket_info_t *result;
_net_nfc_util_alloc_mem(result, sizeof(socket_info_t));
- if (result != NULL) {
+ if (result != NULL)
+ {
result->socket = socket;
llcp_sockets = g_slist_append(llcp_sockets, result);
item = g_slist_find_custom(llcp_sockets, GUINT_TO_POINTER(socket),
_compare_socket_info);
- if (item != NULL) {
+ if (item != NULL)
+ {
llcp_sockets = g_slist_remove_link(llcp_sockets, item);
free(item->data);
}
socket_info_t *info;
info = _get_socket_info(socket);
- if (info != NULL) {
- if (info->err_cb != NULL) {
+ if (info != NULL)
+ {
+ if (info->err_cb != NULL)
info->err_cb(socket, result, NULL, NULL, info->err_param);
- }
_remove_socket_info(socket);
}
socket_info_t *info;
info = _add_socket_info(-1);
- if (info == NULL) {
+ if (NULL == info)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
*result = NET_NFC_ALLOC_FAIL;
return false;
}
ret = g_interface.create_llcp_socket(socket, socketType, miu, rw, result, NULL);
- if (ret == true) {
+ if (true == ret)
+ {
info->socket = *socket;
info->err_cb = cb;
info->err_param = user_param;
- } else {
+ }
+ else
+ {
_remove_socket_info(-1);
}
socket_info_t *info = (socket_info_t *)user_param;
info = _get_socket_info(info->socket);
- if (info != NULL) {
- if (_add_socket_info(socket) != NULL) {
- if (info->work_cb != NULL) {
+ if (info != NULL)
+ {
+ if (_add_socket_info(socket) != NULL)
+ {
+ if (info->work_cb != NULL)
info->work_cb(socket, result, NULL, NULL, info->work_param);
- }
- } else {
+ }
+ else
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
}
}
socket_info_t *info;
info = _get_socket_info(socket);
- if (info == NULL) {
+ if (NULL == info)
+ {
NFC_ERR("_get_socket_info failed");
*result = NET_NFC_INVALID_HANDLE;
return false;
socket_info_t *info;
info = _get_socket_info(socket);
- if (info == NULL) {
+ if (NULL == info)
+ {
NFC_ERR("_get_socket_info failed");
*result = NET_NFC_INVALID_HANDLE;
return false;
bool ret;
ret = g_interface.reject_llcp(handle, socket, result);
- if (ret == true) {
+ if (true == ret)
_remove_socket_info(socket);
- }
return ret;
}
{
net_nfc_llcp_param_t *param = (net_nfc_llcp_param_t *)user_param;
- if (param == NULL)
- return;
+ RET_IF(NULL == param);
- if (param->cb != NULL) {
+ if (param->cb != NULL)
param->cb(param->socket, result, NULL, NULL, param->user_param);
- }
_net_nfc_util_free_mem(param);
}
net_nfc_llcp_param_t *param = NULL;
_net_nfc_util_alloc_mem(param, sizeof(*param));
- if (param == NULL) {
+ if (NULL == param)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
*result = NET_NFC_ALLOC_FAIL;
return false;
{
net_nfc_llcp_param_t *param = (net_nfc_llcp_param_t *)user_param;
- if (param == NULL)
- return;
+ RET_IF(NULL == param);
- if (param->cb != NULL) {
+ if (param->cb != NULL)
param->cb(param->socket, result, NULL, NULL, param->user_param);
- }
_net_nfc_util_free_mem(param);
}
net_nfc_llcp_param_t *param = NULL;
_net_nfc_util_alloc_mem(param, sizeof(net_nfc_llcp_param_t));
- if (param == NULL) {
+ if (NULL == param)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
*result = NET_NFC_ALLOC_FAIL;
return false;
{
net_nfc_llcp_param_t *param = (net_nfc_llcp_param_t *)user_param;
- if (param == NULL)
- return;
+ RET_IF(NULL == param);
- if (param->cb != NULL) {
+ if (param->cb != NULL)
param->cb(param->socket, result, ¶m->data, data, param->user_param);
- }
- if (param->data.buffer != NULL) {
+ if (param->data.buffer != NULL)
_net_nfc_util_free_mem(param->data.buffer);
- }
+
_net_nfc_util_free_mem(param);
}
net_nfc_llcp_param_t *param = NULL;
_net_nfc_util_alloc_mem(param, sizeof(*param));
- if (param == NULL) {
+ if (NULL == param)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
*result = NET_NFC_ALLOC_FAIL;
return false;
param->socket = socket;
param->cb = cb;
- if (max_len > 0) {
+ if (max_len > 0)
+ {
_net_nfc_util_alloc_mem(param->data.buffer, max_len);
- if (param->data.buffer == NULL) {
+ if (param->data.buffer == NULL)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
_net_nfc_util_free_mem(param);
*result = NET_NFC_ALLOC_FAIL;
{
net_nfc_llcp_param_t *param = (net_nfc_llcp_param_t *)user_param;
- if (param == NULL)
- return;
+ RET_IF(NULL == param);
- if (param->cb != NULL) {
+ if (param->cb != NULL)
param->cb(param->socket, result, NULL, NULL, param->user_param);
- }
_net_nfc_util_free_mem(param);
}
net_nfc_llcp_param_t *param = NULL;
_net_nfc_util_alloc_mem(param, sizeof(*param));
- if (param == NULL) {
+ if (NULL == param)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
*result = NET_NFC_ALLOC_FAIL;
return false;
net_nfc_llcp_param_t *param = NULL;
_net_nfc_util_alloc_mem(param, sizeof(*param));
- if (param == NULL) {
+ if (NULL == param)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
*result = NET_NFC_ALLOC_FAIL;
return false;
param->socket = socket;
param->cb = cb;
- if (max_len > 0) {
+ if (max_len > 0)
+ {
_net_nfc_util_alloc_mem(param->data.buffer, max_len);
- if (param->data.buffer == NULL) {
+ if (NULL == param->data.buffer)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
_net_nfc_util_free_mem(param);
*result = NET_NFC_ALLOC_FAIL;
net_nfc_llcp_param_t *param = NULL;
_net_nfc_util_alloc_mem(param, sizeof(*param));
- if (param == NULL) {
+ if (NULL == param)
+ {
NFC_ERR("_net_nfc_util_alloc_mem failed");
*result = NET_NFC_ALLOC_FAIL;
return false;
static NetNfcGDbusHandover *handover_skeleton = NULL;
-static void handover_request_thread_func(gpointer user_data);
-
-static gboolean handover_handle_request(NetNfcGDbusHandover *hdover,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- gint32 arg_type,
- GVariant *smack_privilege,
- gpointer user_data);
-
static void handover_request_thread_func(gpointer user_data)
{
- HandoverRequestData *handover_data = (HandoverRequestData *)user_data;
net_nfc_error_e result;
+ HandoverRequestData *handover_data = user_data;
g_assert(handover_data != NULL);
g_assert(handover_data->handoverobj != NULL);
g_assert(handover_data->invocation != NULL);
result = net_nfc_server_handover_default_client_start(
- GUINT_TO_POINTER(handover_data->handle),
- (void *)handover_data);
+ GUINT_TO_POINTER(handover_data->handle), (void *)handover_data);
if (result != NET_NFC_OK)
{
net_nfc_gdbus_handover_complete_request(
GVariant *smack_privilege,
gpointer user_data)
{
- HandoverRequestData *data;
gboolean result;
+ HandoverRequestData *data;
NFC_INFO(">>> REQUEST from [%s]",
g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ if (net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "rw") == false)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(HandoverRequestData,1);
- if(data == NULL)
+ if(NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
result = net_nfc_server_controller_async_queue_push(
handover_request_thread_func, data);
- if (result == FALSE)
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Handover.ThreadError",
gboolean net_nfc_server_handover_init(GDBusConnection *connection)
{
+ gboolean ret;
GError *error = NULL;
if (handover_skeleton)
handover_skeleton = net_nfc_gdbus_handover_skeleton_new();
- g_signal_connect(handover_skeleton,
- "handle-request",
- G_CALLBACK(handover_handle_request),
- NULL);
+ g_signal_connect(handover_skeleton, "handle-request",
+ G_CALLBACK(handover_handle_request), NULL);
+
+ ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(handover_skeleton),
+ connection, "/org/tizen/NetNfcService/Handover", &error);
- if (g_dbus_interface_skeleton_export(
- G_DBUS_INTERFACE_SKELETON(handover_skeleton),
- connection,
- "/org/tizen/NetNfcService/Handover",
- &error) == FALSE)
+ if (FALSE == ret)
{
g_error_free(error);
wifi_ap_h _net_nfc_handover_bss_create_ap(net_nfc_carrier_config_s *config)
{
- wifi_ap_h ap_handle = NULL;
- data_s temp = { NULL, 0 };
int err = WIFI_ERROR_NONE;
+ data_s temp = { NULL, 0 };
+ wifi_ap_h ap_handle = NULL;
// Sets SSID
err = net_nfc_util_get_carrier_config_property(config,
NET_NFC_WIFI_ATTRIBUTE_SSID,(uint16_t *)&temp.length, &temp.buffer);
+
NFC_DBG("SSID = [%s] err %d",temp.buffer, err);
+
err = wifi_ap_create((char*)temp.buffer, &ap_handle);
if(err != WIFI_ERROR_NONE)
{
// Sets Authentication Type
net_nfc_util_get_carrier_config_property(config,
NET_NFC_WIFI_ATTRIBUTE_AUTH_TYPE,(uint16_t *)&temp.length, &temp.buffer);
+
if(temp.length == 2)
{
uint16_t securitytype = temp.buffer[0] <<8 | temp.buffer[1];
+
NFC_DBG("wifi_ap_set_security_type %x", securitytype);
err = wifi_ap_set_security_type(ap_handle,
_net_nfc_handover_bss_convert_security_type(securitytype));
+
if(err != WIFI_ERROR_NONE)
{
NFC_ERR("set security type failed");
NFC_ERR("Invalid authentication length");
goto error;
}
+
net_nfc_util_get_carrier_config_property(config,
NET_NFC_WIFI_ATTRIBUTE_NET_KEY,(uint16_t *)&temp.length, &temp.buffer);
NFC_ERR("Failed to set passphrase");
goto error;
}
+
// Sets encryption Type
net_nfc_util_get_carrier_config_property(config,
NET_NFC_WIFI_ATTRIBUTE_ENC_TYPE,(uint16_t *)&temp.length, &temp.buffer);
+
if(temp.length == 2)
{
uint16_t enc_type = temp.buffer[0] <<8 | temp.buffer[1];
NFC_ERR("Invalid Encryption length");
goto error;
}
+
return ap_handle;
error:
if(ap_handle != NULL)
void* user_data)
{
net_nfc_handover_bss_process_context_t *context = user_data;
- if(context == NULL)
+ if(NULL == context)
{
NFC_ERR("Invalid context");
return;
}
- if (errorCode == WIFI_ERROR_NONE)
+ if (WIFI_ERROR_NONE == errorCode)
{
NFC_ERR("WIFI activated succesfully");
context->result = NET_NFC_OK;
bool _net_nfc_handover_bss_wifi_for_each_access_point_found(
wifi_ap_h ap_handle, void *user_data)
{
- data_s temp_ssid = { NULL, 0 };
- int err = WIFI_ERROR_NONE;
char* essid = NULL;
+ int err = WIFI_ERROR_NONE;
+ data_s temp_ssid = { NULL, 0 };
net_nfc_handover_bss_process_context_t *context = user_data;
- if(context == NULL)
+ if(NULL == context)
{
NFC_ERR("Invalid context");
return false;
}
wifi_ap_get_essid(ap_handle, &essid);
+
NFC_DBG("Scan Result Ap essid [%s]",essid);
if(memcmp(temp_ssid.buffer, essid,temp_ssid.length) == 0)
{
void _net_nfc_handover_bss_on_wifi_bgscan_completed(
wifi_error_e error_code, void* user_data)
{
-
net_nfc_handover_bss_process_context_t *context = user_data;
- if(context == NULL)
+ if(NULL == context)
{
NFC_ERR("Invalid context");
return;
NFC_ERR("Wifi scan failed");
context->result = NET_NFC_OPERATION_FAIL;
context->step = NET_NFC_LLCP_STEP_RETURN;
- g_idle_add(
- _net_nfc_handover_bss_process_carrier_record,
- context);
+ g_idle_add(_net_nfc_handover_bss_process_carrier_record, context);
}
else
{
NFC_ERR("Wifi scan failed");
context->result = NET_NFC_OPERATION_FAIL;
context->step = NET_NFC_LLCP_STEP_RETURN;
- g_idle_add(
- _net_nfc_handover_bss_process_carrier_record,
- context);
+ g_idle_add(_net_nfc_handover_bss_process_carrier_record, context);
}
else
{
&context->config, context->carrier);
context->ap_handle = NULL;
err = wifi_foreach_found_aps(
- _net_nfc_handover_bss_wifi_for_each_access_point_found,
- context);
+ _net_nfc_handover_bss_wifi_for_each_access_point_found, context);
+
if(err != WIFI_ERROR_NONE)
{
NFC_ERR("wifi_foreach_found_aps failed Err[%x]",err);
context->step = NET_NFC_LLCP_STEP_RETURN;
g_idle_add(_net_nfc_handover_bss_process_carrier_record, context);
}
- if(context->ap_handle == NULL)
+ if(NULL == context->ap_handle)
{
- wifi_encryption_type_e enc_type;
wifi_security_type_e sec_type;
+ wifi_encryption_type_e enc_type;
+
+ context->ap_handle = _net_nfc_handover_bss_create_ap(context->config);
- context->ap_handle = _net_nfc_handover_bss_create_ap(
- context->config);
wifi_ap_get_encryption_type(context->ap_handle, &enc_type);
NFC_DBG("Encryption type %x",enc_type);
+
wifi_ap_get_security_type(context->ap_handle, &sec_type);
NFC_DBG("Authentication type %x", sec_type);
}
else
{
data_s temp = { NULL, 0 };
- wifi_encryption_type_e enc_type = WIFI_ENCRYPTION_TYPE_NONE;
wifi_security_type_e sec_type = WIFI_SECURITY_TYPE_NONE;
+ wifi_encryption_type_e enc_type = WIFI_ENCRYPTION_TYPE_NONE;
+
//set passkey
net_nfc_util_get_carrier_config_property(context->config,
- NET_NFC_WIFI_ATTRIBUTE_NET_KEY,(uint16_t *)&temp.length,
- &temp.buffer);
+ NET_NFC_WIFI_ATTRIBUTE_NET_KEY, (uint16_t *)&temp.length, &temp.buffer);
NFC_ERR("Network Key %s",temp.buffer);
// Sets Network Key
- err = wifi_ap_set_passphrase(context->ap_handle,(char*)temp.buffer);
+ err = wifi_ap_set_passphrase(context->ap_handle, (char*)temp.buffer);
wifi_ap_get_encryption_type(context->ap_handle, &enc_type);
NFC_DBG("Encryption type %x",enc_type);
{
net_nfc_handover_bss_process_context_t *context = user_data;
- if(context == NULL)
+ if(NULL == context)
{
NFC_ERR("Invalid context");
return;
}
- if(error_code == WIFI_ERROR_NONE)
+ if(WIFI_ERROR_NONE == error_code)
{
NFC_ERR("WIFI Connected succesfully");
context->result = NET_NFC_OK;
NFC_ERR("Failed to connect WIFI");
context->result = NET_NFC_OPERATION_FAIL;
}
+
context->step = NET_NFC_LLCP_STEP_RETURN;
g_idle_add(_net_nfc_handover_bss_process_carrier_record,context);
}
net_nfc_handover_bss_process_context_t *context = user_data;
- if(context == NULL)
+ if(NULL == context)
{
NFC_ERR("Invalid context");
NFC_ERR("Handover Failed");
int err = WIFI_ERROR_NONE;
NFC_DBG("STEP [2]");
- err = wifi_scan(_net_nfc_handover_bss_on_wifi_scan_completed,
- context);
+ err = wifi_scan(_net_nfc_handover_bss_on_wifi_scan_completed, context);
if(err != WIFI_ERROR_NONE)
{
NFC_ERR("Wifi scan failed");
case NET_NFC_LLCP_STEP_RETURN :
{
NFC_DBG("STEP return");
- if(context->result == NET_NFC_OK)
+ if(NET_NFC_OK == context->result)
{
NFC_DBG("Handover completed succesfully");
}
NFC_ERR("Handover Failed");
}
wifi_deinitialize();
- context->cb(context->result,
- NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS,
- NULL,
- context->user_param);
+ context->cb(context->result, NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS,
+ NULL, context->user_param);
}
break;
context->step = NET_NFC_LLCP_STEP_RETURN;
context->result = NET_NFC_OPERATION_FAIL;
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
}
}
if(discovery_state == WIFI_DIRECT_ONLY_LISTEN_STARTED && err == WIFI_DIRECT_ERROR_NONE)
{
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
}
else
NFC_ERR("wifi scan error");
context->step = NET_NFC_LLCP_STEP_RETURN;
context->result = NET_NFC_OPERATION_FAIL;
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
}
if(connection_state == WIFI_DIRECT_GROUP_CREATED
&& error_code == WIFI_DIRECT_ERROR_NONE)
{
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
}
else
context->step = NET_NFC_LLCP_STEP_RETURN;
context->result = NET_NFC_OPERATION_FAIL;
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
}
}
{
net_nfc_error_e result;
- if ((result = net_nfc_util_create_handover_carrier_record(
- record)) == NET_NFC_OK)
- {
- NFC_ERR("net_nfc_util_create_ndef_record"
- "_with_carrier_config [%d]",result);
- }
+ result = net_nfc_util_create_handover_carrier_record(record);
+
+ if (NET_NFC_OK == result)
+ NFC_ERR("net_nfc_util_create_ndef_record_with_carrier_config [%d]",result);
else
- {
- NFC_ERR("net_nfc_util_create_carrier_config failed "
- "[%d]", result);
- }
+ NFC_ERR("net_nfc_util_create_carrier_config failed [%d]", result);
return result;
}
FILE *f = fopen("/tmp/nfc_p2p_passphrase.txt","r");
if(f != NULL)
{
- int readlength;
int cnt;
+ int readlength;
readlength = fread(data, 1 , 255, f);
for(cnt = 0; cnt < readlength; cnt++)
{
static net_nfc_error_e _net_nfc_handover_bss_create_config_record(
ndef_record_s **record)
{
- char* mac_address = NULL;
+ int pw_length = 0;
char* ssid = NULL;
+ net_nfc_error_e result;
+ char* mac_address = NULL;
+ data_s enc_type = {NULL,0};
+ data_s mac_data = {NULL,0};
+ data_s ssid_data = {NULL,0};
+ data_s auth_data = {NULL,0};
+ data_s version_data = {NULL,0};
+ data_s net_index_data = {NULL,0};
net_nfc_carrier_config_s *config = NULL;
net_nfc_carrier_property_s *cred_config = NULL;
- net_nfc_error_e result;
+
#if 0
char *passphrase = NULL;
#else
uint8_t *password = NULL;
#endif
- int pw_length = 0;
- data_s version_data = {NULL,0};
- data_s net_index_data = {NULL,0};
- data_s ssid_data = {NULL,0};
- data_s auth_data = {NULL,0};
- data_s enc_type = {NULL,0};
- data_s mac_data = {NULL,0};
_net_nfc_util_alloc_mem(version_data.buffer,1);
if(version_data.buffer)
version_data.length = 1;
*version_data.buffer = 0x01;
- if ((result = net_nfc_util_create_carrier_config(
- &config,
- NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)) == NET_NFC_OK)
+ result = net_nfc_util_create_carrier_config(&config,
+ NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS);
+
+ if (NET_NFC_OK == result)
{
- if ((result = net_nfc_util_add_carrier_config_property(
+ result = net_nfc_util_add_carrier_config_property(
config,
NET_NFC_WIFI_ATTRIBUTE_VERSION,
- version_data.length, version_data.buffer)) != NET_NFC_OK)
+ version_data.length, version_data.buffer);
+
+ if (result != NET_NFC_OK)
{
NFC_ERR("net_nfc_util_add_carrier_config_property failed"
"[%d]", result);
_net_nfc_util_free_mem(version_data.buffer);
}
- if ((result = net_nfc_util_create_carrier_config_group(
- &cred_config,
- NET_NFC_WIFI_ATTRIBUTE_CREDENTIAL)) == NET_NFC_OK)
- {
+ result = net_nfc_util_create_carrier_config_group(&cred_config,
+ NET_NFC_WIFI_ATTRIBUTE_CREDENTIAL);
+ if (NET_NFC_OK == result)
+ {
_net_nfc_util_alloc_mem(net_index_data.buffer,1);
if(net_index_data.buffer)
{
}
net_nfc_util_append_carrier_config_group(config, cred_config);
- result = net_nfc_util_create_ndef_record_with_carrier_config(
- record,
- config);
+ result = net_nfc_util_create_ndef_record_with_carrier_config(record, config);
if (result != NET_NFC_OK)
{
- NFC_ERR("net_nfc_util_create_ndef_record"
- "_with_carrier_config failed"
- "[%d]",result);
+ NFC_ERR("net_nfc_util_create_ndef_record_with_carrier_config failed [%d]",result);
}
return result;
if(context != NULL)
{
-
if (context->result != NET_NFC_OK && context->result != NET_NFC_BUSY)
- {
NFC_ERR("context->result is error [%d]", context->result);
- }
context->result = NET_NFC_OK;
-
context->cps = NET_NFC_CONN_HANDOVER_CARRIER_ACTIVATE;
/* Create carrier record */
- context->result =_net_nfc_handover_bss_create_carrier_record(
- &context->carrier);
+ context->result =_net_nfc_handover_bss_create_carrier_record(&context->carrier);
+
if (context->result!= NET_NFC_OK)
- {
- NFC_ERR("create_bss_config_record failed"
- " [%d]", context->result);
- }
+ NFC_ERR("create_bss_config_record failed [%d]", context->result);
/* complete and return to upper step */
- context->cb(context->result,
- context->cps,
- context->carrier,
- 0,
- NULL,
+ context->cb(context->result, context->cps, context->carrier, 0, NULL,
context->user_param);
}
}
#ifdef TARGET
-static void _net_nfc_wifi_process_error(
- int error,
+static void _net_nfc_wifi_process_error(int error,
net_nfc_handover_bss_get_context_t *context)
{
NFC_ERR("_net_nfc_wifi_process_error - [%d]",error);
context->step = NET_NFC_LLCP_STEP_RETURN;
context->result = NET_NFC_OPERATION_FAIL;
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
return;
return err;
}
- err = wifi_direct_set_device_state_changed_cb(
- _net_nfc_wifi_direct_power_changed,
+ err = wifi_direct_set_device_state_changed_cb(_net_nfc_wifi_direct_power_changed,
context);
if(err != WIFI_DIRECT_ERROR_NONE)
return err;
}
- err = wifi_direct_set_discovery_state_changed_cb(
- _net_nfc_wifi_scan_completed_cb,
+ err = wifi_direct_set_discovery_state_changed_cb(_net_nfc_wifi_scan_completed_cb,
context);
if(err != WIFI_DIRECT_ERROR_NONE)
}
err = wifi_direct_set_connection_state_changed_cb(
- _net_nfc_wifi_direct_connection_changed,
- context);
+ _net_nfc_wifi_direct_connection_changed, context);
if (err != WIFI_DIRECT_ERROR_NONE)
{
NFC_DBG("wifi direct is enabled already");
/* do next step */
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
}
return WIFI_DIRECT_ERROR_NONE;
context->step = NET_NFC_LLCP_STEP_03;
context->result = NET_NFC_OK;
- if(err == WIFI_DIRECT_ERROR_NONE)
+ if(WIFI_DIRECT_ERROR_NONE == err)
{
- if(group_owner == true)
+ if(true == group_owner)
{
NFC_DBG("Already group owner, continue next step");
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
}
else
net_nfc_handover_bss_get_context_t *context)
{
LOGD("[%s:%d] START", __func__, __LINE__);
- if(context == NULL)
+ if(NULL == context)
{
NFC_ERR("Invalid context");
return FALSE;
if (context->result != NET_NFC_OK && context->result != NET_NFC_BUSY)
{
- NFC_ERR("context->result is error"
- " [%d]", context->result);
+ NFC_ERR("context->result is error [%d]", context->result);
context->step = NET_NFC_LLCP_STEP_RETURN;
}
context->step = NET_NFC_LLCP_STEP_RETURN;
/* append config to ndef message */
- context->result =_net_nfc_handover_bss_create_config_record(
- &context->carrier);
+ context->result =_net_nfc_handover_bss_create_config_record(&context->carrier);
if (context->result != NET_NFC_OK)
{
NFC_ERR("_net_nfc_handover_bss_create_config_record failed"
"[%d]", context->result);
}
- g_idle_add((GSourceFunc)
- _net_nfc_handover_bss_wfd_get_carrier_record,
+ g_idle_add((GSourceFunc)_net_nfc_handover_bss_wfd_get_carrier_record,
(gpointer)context);
break;
wifi_direct_deinitialize();
/* complete and return to upper step */
- context->cb(context->result,
- context->cps,
- context->carrier,
- context->aux_data_count,
- context->aux_data,
- context->user_param);
+ context->cb(context->result, context->cps, context->carrier,
+ context->aux_data_count, context->aux_data, context->user_param);
break;
default :
#endif
net_nfc_error_e net_nfc_server_handover_bss_get_carrier_record(
- net_nfc_server_handover_get_carrier_record_cb cb,
- void *user_param)
+ net_nfc_server_handover_get_carrier_record_cb cb, void *user_param)
{
net_nfc_error_e result = NET_NFC_OK;
net_nfc_handover_bss_create_context_t *context = NULL;
context->step = NET_NFC_LLCP_STEP_01;
_net_nfc_handover_bss_get_carrier_record(context);
-
}
else
{
#ifdef TARGET
net_nfc_error_e net_nfc_server_handover_bss_wfd_get_carrier_record(
- net_nfc_server_handover_get_carrier_record_cb cb,
- void *user_param)
+ net_nfc_server_handover_get_carrier_record_cb cb, void *user_param)
{
net_nfc_handover_bss_get_context_t *context = NULL;
net_nfc_carrier_config_s *config,
bt_oob_data_t *oob)
{
- net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
data_s hash = { NULL, 0 };
data_s randomizer = { NULL, 0 };
+ net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
LOGD("[%s:%d] START", __func__, __LINE__);
- if (config == NULL || oob == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == oob, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == config, NET_NFC_NULL_PARAMETER);
memset(oob, 0, sizeof(bt_oob_data_t));
- if ((result = net_nfc_util_get_carrier_config_property(
- config,
- NET_NFC_BT_ATTRIBUTE_OOB_HASH_C,
- (uint16_t *)&hash.length,
- &hash.buffer)) == NET_NFC_OK)
+ result = net_nfc_util_get_carrier_config_property(
+ config,
+ NET_NFC_BT_ATTRIBUTE_OOB_HASH_C,
+ (uint16_t *)&hash.length,
+ &hash.buffer);
+
+ if (NET_NFC_OK == result)
{
if (hash.length == 16)
{
}
}
- if ((result = net_nfc_util_get_carrier_config_property(
+ result = net_nfc_util_get_carrier_config_property(
config,
NET_NFC_BT_ATTRIBUTE_OOB_HASH_R,
(uint16_t *)&randomizer.length,
- &randomizer.buffer)) == NET_NFC_OK)
+ &randomizer.buffer);
+
+ if (NET_NFC_OK == result)
{
if (randomizer.length == 16)
{
};
static void llcp_socket_error_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_incoming_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_connect_by_url_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_connect_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_send_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_send_to_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_receive_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_receive_from_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_disconnect_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-/* client method */
-static void llcp_handle_config_thread_func(gpointer user_data);
-
-static void llcp_handle_listen_thread_func(gpointer user_data);
-
-static void llcp_handle_accept_thread_func(gpointer user_data);
-
-static void llcp_handle_reject_thread_func(gpointer user_data);
-
-static void llcp_handle_connect_thread_func(gpointer user_data);
-
-static void llcp_handle_connect_sap_thread_func(gpointer user_data);
-
-static void llcp_handle_send_thread_func(gpointer user_data);
-
-static void llcp_handle_send_to_thread_func(gpointer user_data);
-
-static void llcp_handle_receive_thread_func(gpointer user_data);
-
-static void llcp_handle_receive_from_thread_func(gpointer user_data);
-
-static void llcp_handle_close_thread_func(gpointer user_data);
-
-static void llcp_handle_disconnect_thread_func(gpointer user_data);
-
-/* methods */
-static gboolean llcp_handle_config(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- GVariant *arg_config,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_listen(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- guint16 arg_miu,
- guint8 arg_rw,
- gint32 arg_type,
- guint8 arg_sap,
- const gchar *arg_service_name,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_connect(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- guint16 arg_miu,
- guint8 arg_rw,
- gint32 arg_type,
- const gchar *arg_service_name,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_connect_sap(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- guint16 arg_miu,
- guint8 arg_rw,
- gint32 arg_type,
- guint8 arg_sap,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_send(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- GVariant *arg_data,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_send_to(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- guint8 arg_sap,
- GVariant *arg_data,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_receive(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- guint32 arg_req_length,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_receive_from(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- guint32 arg_req_length,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_close(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean llcp_handle_disconnect(NetNfcGDbusLlcp *llcp,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- guint32 arg_client_socket,
- GVariant *smack_privilege,
- gpointer user_data);
-
-
-/* simple */
-static void llcp_simple_socket_error_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_simple_listen_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_simple_connect_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_simple_send_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-static void llcp_simple_receive_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param);
-
-
-static void llcp_socket_error_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- llcp_client_data *client_data = (llcp_client_data *)user_param;
+ gboolean ret;
GError *error = NULL;
+ llcp_client_data *client_data = user_param;
- if (g_dbus_connection_emit_signal(
+ ret = g_dbus_connection_emit_signal(
client_data->connection,
client_data->id,
- "/org/tizen/NetNfcService/Llcp",
+ "/org/tizen/NetNfcService/Llcp",
"org.tizen.NetNfcService.Llcp",
"Error",
g_variant_new("(uui)",
- GPOINTER_TO_UINT(client_data->handle),
- socket,
- result),
- &error) == false) {
- if (error != NULL && error->message != NULL) {
+ GPOINTER_TO_UINT(client_data->handle),
+ socket,
+ result),
+ &error);
+
+ if (FALSE == ret)
+ {
+ if (error != NULL && error->message != NULL)
NFC_ERR("g_dbus_connection_emit_signal failed : %s", error->message);
- } else {
+ else
NFC_ERR("g_dbus_connection_emit_signal failed");
- }
}
}
static void llcp_incoming_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- llcp_client_data *client_data = (llcp_client_data *)user_param;
+ gboolean ret;
GError *error = NULL;
+ llcp_client_data *client_data = user_param;
- if (g_dbus_connection_emit_signal(
+ ret = g_dbus_connection_emit_signal(
client_data->connection,
client_data->id,
"/org/tizen/NetNfcService/Llcp",
GPOINTER_TO_UINT(client_data->handle),
client_data->socket,
socket),
- &error) == false) {
- if (error != NULL && error->message != NULL) {
+ &error);
+
+ if (FALSE == ret)
+ {
+ if (error != NULL && error->message != NULL)
NFC_ERR("g_dbus_connection_emit_signal failed : %s", error->message);
- } else {
+ else
NFC_ERR("g_dbus_connection_emit_signal failed");
- }
}
}
static void llcp_connect_by_url_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpConnectData *llcp_data = (LlcpConnectData *)user_param;
+ LlcpConnectData *llcp_data = user_param;
g_assert(llcp_data != NULL);
g_assert(llcp_data->llcp != NULL);
g_assert(llcp_data->invocation != NULL);
- net_nfc_gdbus_llcp_complete_connect(llcp_data->llcp,
- llcp_data->invocation,
- result,
- socket);
+ net_nfc_gdbus_llcp_complete_connect(llcp_data->llcp, llcp_data->invocation,
+ result, socket);
g_free(llcp_data->service_name);
}
static void llcp_connect_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpConnectSapData *llcp_data = (LlcpConnectSapData *)user_param;
+ LlcpConnectSapData *llcp_data = user_param;
g_assert(llcp_data != NULL);
g_assert(llcp_data->llcp != NULL);
g_assert(llcp_data->invocation != NULL);
- net_nfc_gdbus_llcp_complete_connect_sap(
- llcp_data->llcp,
- llcp_data->invocation,
- result,
- socket);
+ net_nfc_gdbus_llcp_complete_connect_sap(llcp_data->llcp, llcp_data->invocation,
+ result, socket);
g_object_unref(llcp_data->invocation);
g_object_unref(llcp_data->llcp);
}
static void llcp_send_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpSendData *llcp_data = (LlcpSendData *)user_param;
+ LlcpSendData *llcp_data = user_param;
g_assert(llcp_data != NULL);
g_assert(llcp_data->llcp != NULL);
g_assert(llcp_data->invocation != NULL);
- net_nfc_gdbus_llcp_complete_send(
- llcp_data->llcp,
- llcp_data->invocation,
- result,
- socket);
+ net_nfc_gdbus_llcp_complete_send(llcp_data->llcp, llcp_data->invocation,
+ result, socket);
net_nfc_util_free_data(&llcp_data->data);
}
static void llcp_send_to_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpSendToData *llcp_data = (LlcpSendToData *)user_param;
+ LlcpSendToData *llcp_data = user_param;
g_assert(llcp_data != NULL);
g_assert(llcp_data->llcp != NULL);
g_assert(llcp_data->invocation != NULL);
- net_nfc_gdbus_llcp_complete_send_to(
- llcp_data->llcp,
- llcp_data->invocation,
- result,
- socket);
+ net_nfc_gdbus_llcp_complete_send_to(llcp_data->llcp, llcp_data->invocation,
+ result, socket);
net_nfc_util_free_data(&llcp_data->data);
g_free(llcp_data);
}
-static void llcp_receive_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+static void llcp_receive_cb(net_nfc_llcp_socket_t socket, net_nfc_error_e result,
+ data_s *data, void *extra, void *user_param)
{
- LlcpReceiveData *llcp_data = (LlcpReceiveData *)user_param;
GVariant *variant;
+ LlcpReceiveData *llcp_data = user_param;
g_assert(llcp_data != NULL);
g_assert(llcp_data->llcp != NULL);
g_assert(llcp_data->invocation != NULL);
variant = net_nfc_util_gdbus_data_to_variant(data);
- net_nfc_gdbus_llcp_complete_receive(
- llcp_data->llcp,
- llcp_data->invocation,
- result,
- variant);
+ net_nfc_gdbus_llcp_complete_receive(llcp_data->llcp, llcp_data->invocation,
+ result, variant);
g_object_unref(llcp_data->invocation);
g_object_unref(llcp_data->llcp);
void *extra,
void *user_param)
{
- LlcpReceiveData *llcp_data = (LlcpReceiveData *)user_param;
GVariant *variant;
+ LlcpReceiveData *llcp_data = user_param;
g_assert(llcp_data != NULL);
g_assert(llcp_data->llcp != NULL);
g_assert(llcp_data->invocation != NULL);
variant = net_nfc_util_gdbus_data_to_variant(data);
- net_nfc_gdbus_llcp_complete_receive_from(
- llcp_data->llcp,
- llcp_data->invocation,
- result,
- (guint8) (int)extra,
- variant);
+ net_nfc_gdbus_llcp_complete_receive_from(llcp_data->llcp, llcp_data->invocation,
+ result, (guint8) (int)extra, variant);
g_object_unref(llcp_data->invocation);
g_object_unref(llcp_data->llcp);
static void llcp_disconnect_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpDisconnectData *llcp_data = (LlcpDisconnectData *)user_param;
+ LlcpDisconnectData *llcp_data = user_param;
g_assert(llcp_data != NULL);
g_assert(llcp_data->llcp != NULL);
g_assert(llcp_data->invocation != NULL);
- net_nfc_gdbus_llcp_complete_disconnect(
- llcp_data->llcp,
- llcp_data->invocation,
- result,
- socket);
+ net_nfc_gdbus_llcp_complete_disconnect(llcp_data->llcp, llcp_data->invocation,
+ result, socket);
g_object_unref(llcp_data->invocation);
g_object_unref(llcp_data->llcp);
static void llcp_handle_config_thread_func(gpointer user_data)
{
- LlcpConfigData *data = (LlcpConfigData *)user_data;
net_nfc_error_e result;
+ LlcpConfigData *data = user_data;
net_nfc_llcp_config_info_s config;
g_assert(data != NULL);
result = net_nfc_server_llcp_set_config(&config);
- net_nfc_gdbus_llcp_complete_config(data->llcp,
- data->invocation,
- result);
+ net_nfc_gdbus_llcp_complete_config(data->llcp, data->invocation, result);
g_object_unref(data->invocation);
g_object_unref(data->llcp);
static void llcp_handle_listen_thread_func(gpointer user_data)
{
- LlcpListenData *data = (LlcpListenData *)user_data;
+ bool ret;
+ net_nfc_error_e result;
llcp_client_data *client_data;
-
+ LlcpListenData *data = user_data;
net_nfc_llcp_socket_t socket = -1;
- net_nfc_error_e result;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
client_data = g_try_new0(llcp_client_data, 1);
- if (client_data == NULL) {
+ if (NULL == client_data)
+ {
result = NET_NFC_ALLOC_FAIL;
goto ERROR;
}
- client_data->connection = g_dbus_method_invocation_get_connection(
- data->invocation);
- client_data->id = g_strdup(
- g_dbus_method_invocation_get_sender(data->invocation));
+ client_data->connection = g_dbus_method_invocation_get_connection(data->invocation);
+ client_data->id = g_strdup(g_dbus_method_invocation_get_sender(data->invocation));
client_data->handle = (net_nfc_target_handle_s*)data->handle;
- if (net_nfc_controller_llcp_create_socket(&socket,
- data->type,
- data->miu,
- data->rw,
- &result,
- llcp_socket_error_cb,
- client_data) == false)
+ ret = net_nfc_controller_llcp_create_socket(&socket, data->type, data->miu, data->rw,
+ &result, llcp_socket_error_cb, client_data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
client_data->socket = socket;
- if (net_nfc_controller_llcp_bind(socket,
- data->sap,
- &result) == false)
+ if (net_nfc_controller_llcp_bind(socket, data->sap, &result) == false)
{
NFC_ERR("net_nfc_controller_llcp_bind failed [%d]", result);
goto ERROR;
}
- if (net_nfc_controller_llcp_listen(GUINT_TO_POINTER(data->handle),
+ ret = net_nfc_controller_llcp_listen(GUINT_TO_POINTER(data->handle),
(uint8_t *)data->service_name,
socket,
&result,
llcp_incoming_cb,
- client_data) == false)
+ client_data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_listen failed [%d]", result);
goto ERROR;
}
- net_nfc_gdbus_llcp_complete_listen(data->llcp, data->invocation,
- result,
+ net_nfc_gdbus_llcp_complete_listen(data->llcp, data->invocation, result,
GPOINTER_TO_UINT(socket));
g_object_unref(data->invocation);
return;
ERROR :
- net_nfc_gdbus_llcp_complete_listen(data->llcp, data->invocation,
- result,
- -1);
+ net_nfc_gdbus_llcp_complete_listen(data->llcp, data->invocation, result, -1);
if (socket != -1)
net_nfc_controller_llcp_socket_close(socket, &result);
static void llcp_handle_accept_thread_func(gpointer user_data)
{
- LlcpAcceptData *data = (LlcpAcceptData *)user_data;
- llcp_client_data *client_data;
+ bool ret;
net_nfc_error_e result;
+ llcp_client_data *client_data;
+ LlcpAcceptData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
client_data = g_try_new0(llcp_client_data, 1);
- if (client_data == NULL) {
+ if (NULL == client_data)
+ {
result = NET_NFC_ALLOC_FAIL;
goto ERROR;
}
- client_data->connection = g_dbus_method_invocation_get_connection(
- data->invocation);
- client_data->id = g_strdup(
- g_dbus_method_invocation_get_sender(data->invocation));
+ client_data->connection = g_dbus_method_invocation_get_connection(data->invocation);
+ client_data->id = g_strdup(g_dbus_method_invocation_get_sender(data->invocation));
client_data->handle = (net_nfc_target_handle_s*)data->handle;
client_data->socket = data->client_socket;
- if (net_nfc_controller_llcp_accept(data->client_socket, &result,
- llcp_socket_error_cb,
- client_data) == false) {
+ ret = net_nfc_controller_llcp_accept(data->client_socket, &result,
+ llcp_socket_error_cb, client_data);
+
+ if (false == ret)
+ {
NFC_ERR("net_nfc_controller_llcp_accept failed [%d]", result);
goto ERROR;
}
- net_nfc_gdbus_llcp_complete_accept(data->llcp, data->invocation,
- result);
+ net_nfc_gdbus_llcp_complete_accept(data->llcp, data->invocation, result);
g_object_unref(data->invocation);
g_object_unref(data->llcp);
return;
ERROR :
- net_nfc_gdbus_llcp_complete_accept(data->llcp, data->invocation,
- result);
+ net_nfc_gdbus_llcp_complete_accept(data->llcp, data->invocation, result);
g_free(client_data);
static void llcp_handle_reject_thread_func(gpointer user_data)
{
- LlcpAcceptData *data = (LlcpAcceptData *)user_data;
+ bool ret;
net_nfc_error_e result;
+ LlcpAcceptData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
- if (net_nfc_controller_llcp_reject(GUINT_TO_POINTER(data->handle),
- data->client_socket,
- &result) == false) {
+ ret = net_nfc_controller_llcp_reject(GUINT_TO_POINTER(data->handle),
+ data->client_socket, &result);
+
+ if (false == ret)
NFC_ERR("net_nfc_controller_llcp_reject failed [%d]", result);
- }
- net_nfc_gdbus_llcp_complete_reject(data->llcp, data->invocation,
- result);
+ net_nfc_gdbus_llcp_complete_reject(data->llcp, data->invocation, result);
g_object_unref(data->invocation);
g_object_unref(data->llcp);
static void llcp_handle_connect_thread_func(gpointer user_data)
{
- LlcpConnectData *data = (LlcpConnectData *)user_data;
+ bool ret;
+ net_nfc_error_e result;
llcp_client_data *client_data;
+ LlcpConnectData *data = user_data;
net_nfc_llcp_socket_t socket = -1;
- net_nfc_error_e result;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
client_data = g_try_new0(llcp_client_data, 1);
- if (client_data == NULL) {
+
+ if (NULL == client_data)
+ {
result = NET_NFC_ALLOC_FAIL;
goto ERROR;
}
- client_data->connection = g_dbus_method_invocation_get_connection(
- data->invocation);
- client_data->id = g_strdup(
- g_dbus_method_invocation_get_sender(data->invocation));
+ client_data->connection = g_dbus_method_invocation_get_connection(data->invocation);
+ client_data->id = g_strdup(g_dbus_method_invocation_get_sender(data->invocation));
client_data->handle = (net_nfc_target_handle_s*)data->handle;
- if (net_nfc_controller_llcp_create_socket(&socket,
- data->type,
- data->miu,
- data->rw,
- &result,
- llcp_socket_error_cb,
- client_data) == false)
+ ret = net_nfc_controller_llcp_create_socket(&socket, data->type, data->miu, data->rw,
+ &result, llcp_socket_error_cb, client_data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
client_data->socket = socket;
- if (net_nfc_controller_llcp_connect_by_url(
+ ret = net_nfc_controller_llcp_connect_by_url(
GUINT_TO_POINTER(data->handle),
socket,
(uint8_t *)data->service_name,
&result,
llcp_connect_by_url_cb,
- data) == false)
+ data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_listen failed [%d]", result);
return;
ERROR :
- net_nfc_gdbus_llcp_complete_connect(data->llcp, data->invocation,
- result,
- -1);
+ net_nfc_gdbus_llcp_complete_connect(data->llcp, data->invocation, result, -1);
if (socket != -1)
net_nfc_controller_llcp_socket_close(socket, &result);
static void llcp_handle_connect_sap_thread_func(gpointer user_data)
{
- LlcpConnectSapData *data = (LlcpConnectSapData *)user_data;
+ bool ret;
llcp_client_data *client_data;
-
net_nfc_llcp_socket_t socket = -1;
net_nfc_error_e result = NET_NFC_OK;
+ LlcpConnectSapData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
client_data = g_try_new0(llcp_client_data, 1);
- if (client_data == NULL) {
+ if (NULL == client_data)
+ {
result = NET_NFC_ALLOC_FAIL;
goto ERROR;
}
- client_data->connection = g_dbus_method_invocation_get_connection(
- data->invocation);
- client_data->id = g_strdup(
- g_dbus_method_invocation_get_sender(data->invocation));
+ client_data->connection = g_dbus_method_invocation_get_connection(data->invocation);
+ client_data->id = g_strdup(g_dbus_method_invocation_get_sender(data->invocation));
client_data->handle = (net_nfc_target_handle_s*)data->handle;
- if (net_nfc_controller_llcp_create_socket(&socket,
- data->type,
- data->miu,
- data->rw,
- &result,
- llcp_socket_error_cb,
- client_data) == false)
+ ret = net_nfc_controller_llcp_create_socket(&socket, data->type, data->miu, data->rw,
+ &result, llcp_socket_error_cb, client_data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
client_data->socket = socket;
- if (net_nfc_controller_llcp_connect(GUINT_TO_POINTER(data->handle),
- socket,
- data->sap,
- &result,
- llcp_connect_cb,
- data) == false)
+ ret = net_nfc_controller_llcp_connect(GUINT_TO_POINTER(data->handle), socket,
+ data->sap, &result, llcp_connect_cb, data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_listen failed [%d]", result);
return;
ERROR :
- net_nfc_gdbus_llcp_complete_connect_sap(data->llcp, data->invocation,
- result,
- -1);
+ net_nfc_gdbus_llcp_complete_connect_sap(data->llcp, data->invocation, result, -1);
if (socket != -1)
net_nfc_controller_llcp_socket_close(socket, &result);
static void llcp_handle_send_thread_func(gpointer user_data)
{
- LlcpSendData *data = (LlcpSendData *)user_data;
+ bool ret;
net_nfc_error_e result;
+ LlcpSendData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
- if (net_nfc_controller_llcp_send(GUINT_TO_POINTER(data->handle),
- data->client_socket,
- &data->data,
- &result,
- llcp_send_cb,
- data) == false)
+ ret = net_nfc_controller_llcp_send(GUINT_TO_POINTER(data->handle),
+ data->client_socket, &data->data, &result, llcp_send_cb, data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_send failed [%d]", result);
- net_nfc_gdbus_llcp_complete_send(data->llcp,
- data->invocation,
- result,
+ net_nfc_gdbus_llcp_complete_send(data->llcp, data->invocation, result,
data->client_socket);
net_nfc_util_free_data(&data->data);
static void llcp_handle_send_to_thread_func(gpointer user_data)
{
- LlcpSendToData *data = (LlcpSendToData *)user_data;
+ bool ret;
net_nfc_error_e result;
+ LlcpSendToData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
- if (net_nfc_controller_llcp_send_to(GUINT_TO_POINTER(data->handle),
+ ret = net_nfc_controller_llcp_send_to(GUINT_TO_POINTER(data->handle),
data->client_socket,
&data->data,
data->sap,
&result,
llcp_send_to_cb,
- data) == false)
+ data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_send_to failed [%d]", result);
- net_nfc_gdbus_llcp_complete_send_to(data->llcp,
- data->invocation,
- result,
+ net_nfc_gdbus_llcp_complete_send_to(data->llcp, data->invocation, result,
data->client_socket);
net_nfc_util_free_data(&data->data);
static void llcp_handle_receive_thread_func(gpointer user_data)
{
- LlcpReceiveData *data = (LlcpReceiveData *)user_data;
+ bool ret;
net_nfc_error_e result;
+ LlcpReceiveData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
- if (net_nfc_controller_llcp_recv(GUINT_TO_POINTER(data->handle),
+ ret = net_nfc_controller_llcp_recv(GUINT_TO_POINTER(data->handle),
data->client_socket,
data->req_length,
&result,
llcp_receive_cb,
- data) == false)
+ data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_recv failed [%d]", result);
- net_nfc_gdbus_llcp_complete_receive(data->llcp,
- data->invocation,
- result,
+ net_nfc_gdbus_llcp_complete_receive(data->llcp, data->invocation, result,
net_nfc_util_gdbus_buffer_to_variant(NULL, 0));
g_object_unref(data->invocation);
static void llcp_handle_receive_from_thread_func(gpointer user_data)
{
- LlcpReceiveData *data = (LlcpReceiveData *)user_data;
+ bool ret;
net_nfc_error_e result;
+ LlcpReceiveData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
g_assert(data->invocation != NULL);
- if (net_nfc_controller_llcp_recv_from(GUINT_TO_POINTER(data->handle),
+ ret = net_nfc_controller_llcp_recv_from(GUINT_TO_POINTER(data->handle),
data->client_socket,
data->req_length,
&result,
llcp_receive_from_cb,
- data) == false)
+ data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_recv_from failed [%d]", result);
- net_nfc_gdbus_llcp_complete_receive_from(data->llcp,
- data->invocation,
- result,
- -1,
+ net_nfc_gdbus_llcp_complete_receive_from(data->llcp, data->invocation, result, -1,
net_nfc_util_gdbus_buffer_to_variant(NULL, 0));
g_object_unref(data->invocation);
static void llcp_handle_close_thread_func(gpointer user_data)
{
- LlcpCloseData *data = (LlcpCloseData *)user_data;
net_nfc_error_e result;
+ LlcpCloseData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
net_nfc_controller_llcp_socket_close(data->client_socket, &result);
- net_nfc_gdbus_llcp_complete_close(data->llcp,
- data->invocation,
- result,
+ net_nfc_gdbus_llcp_complete_close(data->llcp, data->invocation, result,
data->client_socket);
}
static void llcp_handle_disconnect_thread_func(gpointer user_data)
{
- LlcpDisconnectData *data = (LlcpDisconnectData *)user_data;
+ bool ret;
net_nfc_error_e result;
+ LlcpDisconnectData *data = user_data;
g_assert(data != NULL);
g_assert(data->llcp != NULL);
NFC_DBG("net_nfc_controller_disconnect pm_unlock_state[%d]!!", ret_val);
}
- if (net_nfc_controller_llcp_disconnect(GUINT_TO_POINTER(data->handle),
- data->client_socket,
- &result,
- llcp_disconnect_cb,
- data) == false)
+ ret = net_nfc_controller_llcp_disconnect(GUINT_TO_POINTER(data->handle),
+ data->client_socket, &result, llcp_disconnect_cb, data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_disconnect failed [%d]", result);
- net_nfc_gdbus_llcp_complete_disconnect(data->llcp,
- data->invocation,
- result,
+ net_nfc_gdbus_llcp_complete_disconnect(data->llcp, data->invocation, result,
data->client_socket);
g_object_unref(data->invocation);
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpConfigData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpConfigData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.AllocationError",
"Can not allocate memory");
data->llcp = g_object_ref(llcp);
data->invocation = g_object_ref(invocation);
- g_variant_get(arg_config,
- "(qqyy)",
- &data->miu,
- &data->wks,
- &data->lto,
- &data->option);
+ g_variant_get(arg_config, "(qqyy)", &data->miu, &data->wks, &data->lto, &data->option);
result = net_nfc_server_controller_async_queue_push(
- llcp_handle_config_thread_func,
- data);
- if (result == FALSE)
+ llcp_handle_config_thread_func, data);
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpListenData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpListenData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.AllocationError",
"Can not allocate memory");
data->sap = arg_sap;
data->service_name = g_strdup(arg_service_name);
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_listen_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_listen_thread_func,
data);
- if (result == FALSE)
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpAcceptData *data;
g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpAcceptData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Llcp.MemoryError",
- "Out of memory");
+ "org.tizen.NetNfcService.Llcp.MemoryError", "Out of memory");
return FALSE;
}
data->handle = arg_handle;
data->client_socket = arg_client_socket;
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_accept_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_accept_thread_func,
data);
- if (result == FALSE)
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpAcceptData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpAcceptData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Llcp.MemoryError",
- "Out of memory");
+ "org.tizen.NetNfcService.Llcp.MemoryError", "Out of memory");
return FALSE;
}
data->handle = arg_handle;
data->client_socket = arg_client_socket;
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_reject_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_reject_thread_func,
data);
- if (result == FALSE)
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpConnectData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpConnectData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->type = arg_type;
data->service_name = g_strdup(arg_service_name);
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_connect_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_connect_thread_func,
data);
- if (result == FALSE)
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpConnectSapData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpConnectSapData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->sap = arg_sap;
result = net_nfc_server_controller_async_queue_push(
- llcp_handle_connect_sap_thread_func,
- data);
- if (result == FALSE)
+ llcp_handle_connect_sap_thread_func, data);
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpSendData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpSendData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_send_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_send_thread_func,
data);
- if (result == FALSE)
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpSendToData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpSendToData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_send_to_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_send_to_thread_func,
data);
- if (result == FALSE)
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpReceiveData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "w");
+
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpReceiveData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->client_socket = arg_client_socket;
data->req_length = arg_req_length;
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_receive_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_receive_thread_func,
data);
- if (result == FALSE)
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpReceiveData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
+
+ ret == net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "w");
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "w") == false) {
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpReceiveData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->req_length = arg_req_length;
result = net_nfc_server_controller_async_queue_push(
- llcp_handle_receive_from_thread_func,
- data);
- if (result == FALSE)
+ llcp_handle_receive_from_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpCloseData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
+ ret == net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "w");
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "w") == false) {
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpCloseData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->handle = arg_handle;
data->client_socket = arg_client_socket;
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_close_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_close_thread_func,
data);
- if (result == FALSE)
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
LlcpDisconnectData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
+ ret == net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "w");
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "w") == false) {
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(LlcpDisconnectData, 1);
- if (data == NULL) {
+ if (NULL == data)
+ {
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->handle = arg_handle;
data->client_socket = arg_client_socket;
- result = net_nfc_server_controller_async_queue_push(
- llcp_handle_disconnect_thread_func,
+ result = net_nfc_server_controller_async_queue_push(llcp_handle_disconnect_thread_func,
data);
- if (result == FALSE)
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Llcp.ThreadError",
void net_nfc_server_llcp_deactivated(gpointer user_data)
{
- net_nfc_target_handle_s *handle = (net_nfc_target_handle_s *)user_data;
+ net_nfc_target_handle_s *handle = user_data;
if (handle != NULL)
{
if (net_nfc_controller_disconnect(handle, &result) == false)
{
if (result != NET_NFC_NOT_CONNECTED)
- {
net_nfc_controller_exception_handler();
- }
else
- {
NFC_ERR("target was not connected.");
- }
}
net_nfc_server_set_state(NET_NFC_SERVER_IDLE);
}
static void llcp_simple_socket_error_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+ LlcpSimpleData *simple_data = user_param;
g_assert(simple_data != NULL);
if (simple_data->error_callback)
{
- simple_data->error_callback(result,
- simple_data->handle,
- socket,
- data,
+ simple_data->error_callback(result, simple_data->handle, socket, data,
simple_data->user_data);
}
}
static void llcp_simple_listen_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+ LlcpSimpleData *simple_data = user_param;
g_assert(simple_data != NULL);
- if (result != NET_NFC_OK) {
+ if (result != NET_NFC_OK)
NFC_ERR("listen socket failed, [%d]", result);
- }
if (simple_data->callback)
{
- simple_data->callback(result,
- simple_data->handle,
- socket,
- data,
+ simple_data->callback(result, simple_data->handle, socket, data,
simple_data->user_data);
}
}
static void llcp_simple_connect_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+ LlcpSimpleData *simple_data = user_param;
g_assert(simple_data != NULL);
- if (result != NET_NFC_OK) {
+ if (result != NET_NFC_OK)
NFC_ERR("connect socket failed, [%d]", result);
- }
if (simple_data->callback)
{
- simple_data->callback(result,
- simple_data->handle,
- socket,
- data,
+ simple_data->callback(result, simple_data->handle, socket, data,
simple_data->user_data);
}
}
static void llcp_simple_send_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+ LlcpSimpleData *simple_data = user_param;
g_assert(simple_data != NULL);
if (simple_data->callback)
{
- simple_data->callback(result,
- simple_data->handle,
- socket,
- data,
+ simple_data->callback(result, simple_data->handle, socket, data,
simple_data->user_data);
}
}
static void llcp_simple_receive_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
- LlcpSimpleData *simple_data = (LlcpSimpleData *)user_param;
+ LlcpSimpleData *simple_data = user_param;
g_assert(simple_data != NULL);
if (simple_data->callback)
{
- simple_data->callback(result,
- simple_data->handle,
- socket,
- data,
+ simple_data->callback(result, simple_data->handle, socket, data,
simple_data->user_data);
}
llcp_skeleton = net_nfc_gdbus_llcp_skeleton_new();
- g_signal_connect(llcp_skeleton,
- "handle-config",
- G_CALLBACK(llcp_handle_config),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-listen",
- G_CALLBACK(llcp_handle_listen),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-accept",
- G_CALLBACK(llcp_handle_accept),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-reject",
- G_CALLBACK(llcp_handle_reject),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-connect",
- G_CALLBACK(llcp_handle_connect),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-connect-sap",
- G_CALLBACK(llcp_handle_connect_sap),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-send",
- G_CALLBACK(llcp_handle_send),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-send-to",
- G_CALLBACK(llcp_handle_send_to),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-receive",
- G_CALLBACK(llcp_handle_receive),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-receive-from",
- G_CALLBACK(llcp_handle_receive_from),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-close",
- G_CALLBACK(llcp_handle_close),
- NULL);
-
- g_signal_connect(llcp_skeleton,
- "handle-disconnect",
- G_CALLBACK(llcp_handle_disconnect),
- NULL);
-
- result = g_dbus_interface_skeleton_export(
- G_DBUS_INTERFACE_SKELETON(llcp_skeleton),
- connection,
- "/org/tizen/NetNfcService/Llcp",
- &error);
- if (result == FALSE)
+ g_signal_connect(llcp_skeleton, "handle-config",
+ G_CALLBACK(llcp_handle_config), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-listen",
+ G_CALLBACK(llcp_handle_listen), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-accept",
+ G_CALLBACK(llcp_handle_accept), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-reject",
+ G_CALLBACK(llcp_handle_reject), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-connect",
+ G_CALLBACK(llcp_handle_connect), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-connect-sap",
+ G_CALLBACK(llcp_handle_connect_sap), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-send", G_CALLBACK(llcp_handle_send), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-send-to",
+ G_CALLBACK(llcp_handle_send_to), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-receive",
+ G_CALLBACK(llcp_handle_receive), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-receive-from",
+ G_CALLBACK(llcp_handle_receive_from), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-close", G_CALLBACK(llcp_handle_close), NULL);
+
+ g_signal_connect(llcp_skeleton, "handle-disconnect",
+ G_CALLBACK(llcp_handle_disconnect), NULL);
+
+ result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(llcp_skeleton),
+ connection, "/org/tizen/NetNfcService/Llcp", &error);
+ if (FALSE == result)
{
g_error_free(error);
{
net_nfc_error_e result;
- if (config == NULL)
+ if (NULL == config)
{
net_nfc_controller_llcp_config(&llcp_config, &result);
return result;
net_nfc_server_llcp_callback error_callback,
gpointer user_data)
{
- net_nfc_error_e result = NET_NFC_OK;
- LlcpSimpleData *simple_data = NULL;
+ bool ret;
net_nfc_llcp_socket_t socket = -1;
net_nfc_llcp_config_info_s config;
+ net_nfc_error_e result = NET_NFC_OK;
+ LlcpSimpleData *simple_data = NULL;
- if (handle == NULL)
+ if (NULL == handle)
return NET_NFC_NULL_PARAMETER;
- if (net_nfc_controller_llcp_get_remote_config(handle,
- &config,
- &result) == false)
+ if (net_nfc_controller_llcp_get_remote_config(handle, &config, &result) == false)
{
NFC_ERR("net_nfc_controller_llcp_get_remote_config failed [%d]", result);
}
simple_data = g_try_new0(LlcpSimpleData, 1);
- if (simple_data == NULL) {
+ if (NULL == simple_data)
+ {
NFC_ERR("g_try_new0 failed");
result = NET_NFC_ALLOC_FAIL;
simple_data->miu = MIN(config.miu, net_nfc_server_llcp_get_miu());
- if (net_nfc_controller_llcp_create_socket(&socket,
+ ret = net_nfc_controller_llcp_create_socket(&socket,
NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED,
simple_data->miu,
1,
&result,
llcp_simple_socket_error_cb,
- simple_data) == false)
+ simple_data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
simple_data->socket = socket;
- if (net_nfc_controller_llcp_bind(socket,
- sap,
- &result) == false)
+ if (net_nfc_controller_llcp_bind(socket, sap, &result) == false)
{
NFC_ERR("net_nfc_controller_llcp_bind failed [%d]", result);
goto ERROR;
}
- if (net_nfc_controller_llcp_listen(handle,
- (uint8_t *)san,
- socket,
- &result,
- llcp_simple_listen_cb,
- simple_data) == false)
+ ret = net_nfc_controller_llcp_listen(handle, (uint8_t *)san, socket, &result,
+ llcp_simple_listen_cb, simple_data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_listen failed [%d]", result);
return result;
ERROR :
- if (socket != -1) {
+ if (socket != -1)
+ {
net_nfc_error_e temp;
net_nfc_controller_llcp_socket_close(socket, &temp);
}
- if (simple_data != NULL) {
+ if (simple_data != NULL)
g_free(simple_data);
- }
return result;
}
net_nfc_server_llcp_callback error_callback,
gpointer user_data)
{
+ bool ret;
net_nfc_error_e result;
- LlcpSimpleData *simple_data = NULL;
net_nfc_llcp_socket_t socket = -1;
net_nfc_llcp_config_info_s config;
+ LlcpSimpleData *simple_data = NULL;
- if (handle == NULL)
+ if (NULL == handle)
return NET_NFC_NULL_PARAMETER;
- if (net_nfc_controller_llcp_get_remote_config(handle,
- &config,
- &result) == false)
+ if (net_nfc_controller_llcp_get_remote_config(handle, &config, &result) == false)
{
NFC_ERR("net_nfc_controller_llcp_get_remote_config failed [%d]", result);
}
simple_data = g_try_new0(LlcpSimpleData, 1);
- if (simple_data == NULL) {
+ if (NULL == simple_data)
+ {
NFC_ERR("g_try_new0 failed");
result = NET_NFC_ALLOC_FAIL;
simple_data->miu = MIN(config.miu, net_nfc_server_llcp_get_miu());
- if (net_nfc_controller_llcp_create_socket(&socket,
+ ret = net_nfc_controller_llcp_create_socket(&socket,
NET_NFC_LLCP_SOCKET_TYPE_CONNECTIONORIENTED,
simple_data->miu,
1,
&result,
llcp_simple_socket_error_cb,
- simple_data) == false)
+ simple_data);
+
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_create_socket failed [%d]", result);
simple_data->socket = socket;
- if (san == NULL)
+ if (NULL == san)
{
- if (net_nfc_controller_llcp_connect(handle,
- simple_data->socket,
- sap,
- &result,
- llcp_simple_connect_cb,
- simple_data) == false)
+ ret = net_nfc_controller_llcp_connect(handle, simple_data->socket, sap,
+ &result, llcp_simple_connect_cb, simple_data);
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_connect failed [%d]", result);
}
else
{
- if (net_nfc_controller_llcp_connect_by_url(handle,
- simple_data->socket,
- (uint8_t *)san,
- &result,
- llcp_simple_connect_cb,
- simple_data) == false)
+ ret = net_nfc_controller_llcp_connect_by_url(handle, simple_data->socket,
+ (uint8_t *)san, &result, llcp_simple_connect_cb, simple_data);
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_connect_by_url failed [%d]", result);
return result;
ERROR :
- if (socket != -1) {
+ if (socket != -1)
+ {
net_nfc_error_e temp;
net_nfc_controller_llcp_socket_close(socket, &temp);
}
- if (simple_data != NULL) {
+ if (simple_data != NULL)
g_free(simple_data);
- }
return result;
}
net_nfc_server_llcp_callback error_callback,
gpointer user_data)
{
+ bool ret;
net_nfc_error_e result;
LlcpSimpleData *simple_data;
simple_data = g_try_new0(LlcpSimpleData, 1);
- if (simple_data != NULL) {
+ if (simple_data != NULL)
+ {
simple_data->handle = handle;
simple_data->socket = socket;
simple_data->error_callback = error_callback;
simple_data->user_data = user_data;
- if (net_nfc_controller_llcp_accept(socket,
- &result,
- llcp_simple_socket_error_cb,
- simple_data) == false)
- {
+ ret = net_nfc_controller_llcp_accept(socket, &result,
+ llcp_simple_socket_error_cb, simple_data);
+ if (false == ret)
NFC_ERR("net_nfc_controller_llcp_accept failed [%d]", result);
- }
- } else {
+ }
+ else
+ {
NFC_ERR("g_try_new0 failed");
result = NET_NFC_ALLOC_FAIL;
net_nfc_server_llcp_callback callback,
gpointer user_data)
{
+ bool ret;
net_nfc_error_e result;
LlcpSimpleData *simple_data;
simple_data = g_try_new0(LlcpSimpleData, 1);
- if (simple_data != NULL) {
+ if (simple_data != NULL)
+ {
simple_data->handle = handle;
simple_data->socket = socket;
simple_data->callback = callback;
simple_data->user_data = user_data;
- if (net_nfc_controller_llcp_send(handle,
- socket,
- data,
- &result,
- llcp_simple_send_cb,
- simple_data) == false)
- {
- NFC_ERR("net_nfc_controller_llcp_send failed [%d]",
- result);
- }
- } else {
+ ret = net_nfc_controller_llcp_send(handle, socket, data, &result,
+ llcp_simple_send_cb, simple_data);
+
+ if (false == ret)
+ NFC_ERR("net_nfc_controller_llcp_send failed [%d]", result);
+ }
+ else
+ {
NFC_ERR("g_try_new0 failed");
result = NET_NFC_ALLOC_FAIL;
}
- if (result == NET_NFC_BUSY)
+ if (NET_NFC_BUSY == result)
result = NET_NFC_OK;
return result;
net_nfc_server_llcp_callback callback,
gpointer user_data)
{
+ bool ret;
net_nfc_error_e result;
LlcpSimpleData *simple_data;
simple_data = g_try_new0(LlcpSimpleData, 1);
- if (simple_data != NULL) {
+ if (simple_data != NULL)
+ {
simple_data->handle = handle;
simple_data->socket = socket;
simple_data->callback = callback;
simple_data->user_data = user_data;
- if (net_nfc_controller_llcp_recv(handle,
- socket,
- net_nfc_server_llcp_get_miu(),
- &result,
- llcp_simple_receive_cb,
- simple_data) == false)
+ ret = net_nfc_controller_llcp_recv(handle, socket, net_nfc_server_llcp_get_miu(),
+ &result, llcp_simple_receive_cb, simple_data);
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_llcp_recv failed [%d]", result);
g_free(simple_data);
}
- } else {
+ }
+ else
+ {
NFC_ERR("g_try_new0 failed");
result = NET_NFC_ALLOC_FAIL;
}
- if (result == NET_NFC_BUSY)
+ if (NET_NFC_BUSY == result)
result = NET_NFC_OK;
return result;
static void _llcp_init()
{
- if (service_table == NULL)
+ if (NULL == service_table)
service_table = g_hash_table_new(NULL, NULL);
}
inline static service_t *_llcp_find_service(uint32_t sap)
{
- return (service_t *)g_hash_table_lookup(service_table,
- (gconstpointer)sap);
+ return (service_t *)g_hash_table_lookup(service_table, (gconstpointer)sap);
}
static net_nfc_error_e _llcp_add_service(const char *id, uint32_t sap,
const char *san, net_nfc_server_llcp_activate_cb cb, void *user_data)
{
- service_t *service = NULL;
net_nfc_error_e result;
+ service_t *service = NULL;
- if (cb == NULL) {
- NFC_ERR("callback is mandatory");
-
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == cb, NET_NFC_NULL_PARAMETER);
_llcp_init();
- if (_llcp_find_service(sap) == NULL) {
+ if (_llcp_find_service(sap) == NULL)
+ {
NFC_DBG("new service, sap [%d]", sap);
service = g_try_new0(service_t, 1);
- if (service != NULL) {
+ if (service != NULL)
+ {
service->sap = sap;
- if (san != NULL && strlen(san) > 0) {
+ if (san != NULL && strlen(san) > 0)
service->san = g_strdup(san);
- }
- if (id != NULL && strlen(id) > 0) {
+
+ if (id != NULL && strlen(id) > 0)
service->id = g_strdup(id);
- }
+
service->cb = cb;
service->user_data = user_data;
- g_hash_table_insert(service_table, (gpointer)sap,
- (gpointer)service);
+ g_hash_table_insert(service_table, (gpointer)sap, (gpointer)service);
result = NET_NFC_OK;
- } else {
+ }
+ else
+ {
NFC_ERR("alloc failed");
result = NET_NFC_ALLOC_FAIL;
service_t *service = NULL;
service = _llcp_find_service(sap);
- if (service != NULL) {
+ if (service != NULL)
+ {
g_free(service->san);
g_free(service->id);
g_free(service);
static void _llcp_remove_services(const char *id)
{
- GHashTableIter iter;
gpointer key;
service_t *service;
+ GHashTableIter iter;
- if (service_table == NULL)
+ if (NULL == service_table)
return;
g_hash_table_iter_init (&iter, service_table);
- while (g_hash_table_iter_next (&iter, &key, (gpointer)&service)) {
- if (id == NULL || strcmp(service->id, id) == 0) {
+ while (g_hash_table_iter_next (&iter, &key, (gpointer)&service))
+ {
+ if (id == NULL || strcmp(service->id, id) == 0)
+ {
g_free(service->san);
g_free(service->id);
g_free(service);
net_nfc_error_e net_nfc_server_llcp_unregister_service(const char *id,
sap_t sap, const char *san)
{
- net_nfc_error_e result;
service_t *service;
+ net_nfc_error_e result;
service = _llcp_find_service(sap);
- if (service != NULL) {
+ if (service != NULL)
+ {
/* invoke callback */
service->cb(NET_NFC_LLCP_UNREGISTERED, NULL, service->sap,
service->san, service->user_data);
_llcp_remove_service(sap);
result = NET_NFC_OK;
- } else {
+ }
+ else
+ {
NFC_ERR("service is not registered");
result = NET_NFC_NOT_REGISTERED;
net_nfc_error_e net_nfc_server_llcp_unregister_all()
{
- GHashTableIter iter;
gpointer key;
service_t *service;
+ GHashTableIter iter;
- if (service_table == NULL)
+ if (NULL == service_table)
return NET_NFC_OK;
g_hash_table_iter_init(&iter, service_table);
- while (g_hash_table_iter_next(&iter, &key, (gpointer)&service)) {
+ while (g_hash_table_iter_next(&iter, &key, (gpointer)&service))
+ {
service->cb(NET_NFC_LLCP_UNREGISTERED, NULL, service->sap,
service->san, service->user_data);
static void net_nfc_server_llcp_process(gpointer user_data)
{
+ bool ret;
+ net_nfc_target_handle_s *handle;
net_nfc_current_target_info_s *target;
#if 0
net_nfc_error_e result;
net_nfc_target_type_e dev_type;
#endif
- net_nfc_target_handle_s *handle;
target = net_nfc_server_get_target_info();
#if 0
dev_type = target->devType;
- if (dev_type == NET_NFC_NFCIP1_TARGET)
+ if (NET_NFC_NFCIP1_TARGET == dev_type)
{
NFC_DBG("LLCP : target, try to connect");
{
NFC_ERR("net_nfc_controller_connect is failed, [%d]", result);
- if (net_nfc_controller_configure_discovery(
- NET_NFC_DISCOVERY_MODE_RESUME,
- NET_NFC_ALL_ENABLE,
- &result) == false)
+ ret = net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_RESUME,
+ NET_NFC_ALL_ENABLE, &result);
+ if (false == ret)
{
NFC_ERR("net_nfc_controller_configure_discovery is failed [%d]", result);
net_nfc_controller_exception_handler();
if (net_nfc_controller_llcp_activate_llcp(handle, &result) == false)
{
- NFC_ERR("%s is failed [%d]",
- "net_nfc_controller_llcp_activate_llcp",
- result);
+ NFC_ERR("%s is failed [%d]", "net_nfc_controller_llcp_activate_llcp", result);
return;
}
void net_nfc_server_llcp_target_detected(void *info)
{
- if (net_nfc_server_controller_async_queue_push(
- net_nfc_server_llcp_process, NULL) == FALSE)
- {
+ gboolean ret;
+
+ ret = net_nfc_server_controller_async_queue_push(
+ net_nfc_server_llcp_process, NULL);
+
+ if (FALSE == ret)
NFC_ERR("can not push to controller thread");
- }
+
}
static NetNfcGDbusManager *manager_skeleton = NULL;
-static net_nfc_error_e manager_active(void);
-
-static net_nfc_error_e manager_deactive(void);
-
-static void manager_handle_active_thread_func(gpointer user_data);
-
-static gboolean manager_handle_set_active(NetNfcGDbusManager *manager,
- GDBusMethodInvocation *invocation,
- gboolean arg_is_active,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean manager_handle_get_server_state(NetNfcGDbusManager *manager,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data);
-
-
-static void manager_active_thread_func(gpointer user_data);
-
/* reimplementation of net_nfc_service_init()*/
static net_nfc_error_e manager_active(void)
{
- net_nfc_error_e result;
int ret;
int se_type;
+ net_nfc_error_e result;
if (net_nfc_controller_is_ready(&result) == false)
{
/* keep_SE_select_value */
ret = vconf_get_int(VCONFKEY_NFC_SE_TYPE, &se_type);
- if (ret == 0)
+ if (0 == ret)
{
- NFC_DBG("manager_active se_type [%d]",se_type);
+ NFC_DBG("manager_active se_type [%d]",se_type);
result = net_nfc_server_se_change_se(se_type);
}
/* register default handover server */
net_nfc_server_handover_default_server_register();
- if (net_nfc_controller_configure_discovery(
- NET_NFC_DISCOVERY_MODE_START,
- NET_NFC_ALL_ENABLE,
- &result) == TRUE)
+ if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_START,
+ NET_NFC_ALL_ENABLE, &result) == TRUE)
{
/* vconf on */
if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0)
/* reimplementation of net_nfc_service_deinit()*/
static net_nfc_error_e manager_deactive(void)
{
+ bool ret;
net_nfc_error_e result;
if (net_nfc_controller_is_ready(&result) == false)
/* keep_SE_select_value do not need to update vconf and gdbus_se_setting */
result = net_nfc_server_se_disable_card_emulation();
- if (net_nfc_controller_configure_discovery(
- NET_NFC_DISCOVERY_MODE_STOP,
- NET_NFC_ALL_DISABLE,
- &result) == TRUE)
+ ret = net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_STOP,
+ NET_NFC_ALL_DISABLE, &result);
+
+ if (TRUE == ret)
{
/* vconf off */
if (vconf_set_bool(VCONFKEY_NFC_STATE, FALSE) != 0)
static void manager_handle_active_thread_func(gpointer user_data)
{
- ManagerActivationData *data = (ManagerActivationData *)user_data;
net_nfc_error_e result;
+ ManagerActivationData *data = user_data;
g_assert(data != NULL);
g_assert(data->manager != NULL);
else
result = manager_deactive();
- net_nfc_gdbus_manager_complete_set_active(data->manager,
- data->invocation,
- result);
+ net_nfc_gdbus_manager_complete_set_active(data->manager, data->invocation, result);
- if (result == NET_NFC_OK) {
- NFC_INFO("nfc %s", data->is_active ?
- "activated" : "deactivated");
+ if (NET_NFC_OK == result)
+ {
+ NFC_INFO("nfc %s", data->is_active ? "activated" : "deactivated");
- net_nfc_gdbus_manager_emit_activated(data->manager,
- data->is_active);
- } else {
+ net_nfc_gdbus_manager_emit_activated(data->manager, data->is_active);
+ }
+ else
+ {
NFC_ERR("activation change failed, [%d]", result);
}
g_free(data);
/* shutdown process if it doesn't need */
- if (data->is_active == false &&
- net_nfc_server_gdbus_is_server_busy() == false) {
-
+ if (data->is_active == false && net_nfc_server_gdbus_is_server_busy() == false)
net_nfc_server_controller_deinit();
- }
}
GVariant *smack_privilege,
gpointer user_data)
{
- ManagerActivationData *data;
+ bool ret;
gboolean result;
+ ManagerActivationData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::admin",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::admin", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
NFC_DBG("is_active %d", arg_is_active);
data = g_try_new0(ManagerActivationData, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
result = net_nfc_server_controller_async_queue_push(
manager_handle_active_thread_func, data);
- if (result == FALSE)
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.ThreadError",
}
static gboolean manager_handle_get_server_state(NetNfcGDbusManager *manager,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data)
+ GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
{
+ bool ret;
guint32 state;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::admin",
- "r") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::admin", "r");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
state = net_nfc_server_get_state();
- net_nfc_gdbus_manager_complete_get_server_state(manager,
- invocation,
- NET_NFC_OK,
+ net_nfc_gdbus_manager_complete_get_server_state(manager, invocation, NET_NFC_OK,
state);
+
return TRUE;
}
/* server side */
static void manager_active_thread_func(gpointer user_data)
{
- ManagerActivationData *data =
- (ManagerActivationData *)user_data;
net_nfc_error_e ret;
+ ManagerActivationData *data = user_data;
g_assert(data != NULL);
ret = manager_active();
else
ret = manager_deactive();
- if (ret == NET_NFC_OK)
+
+ if (NET_NFC_OK == ret)
{
- NFC_INFO("nfc %s",
- data->is_active ? "activated" : "deactivated");
+ NFC_INFO("nfc %s", data->is_active ? "activated" : "deactivated");
net_nfc_gdbus_manager_emit_activated(data->manager, data->is_active);
}
gboolean net_nfc_server_manager_init(GDBusConnection *connection)
{
+ gboolean ret;
GError *error = NULL;
if (manager_skeleton)
manager_skeleton = net_nfc_gdbus_manager_skeleton_new();
- g_signal_connect(manager_skeleton,
- "handle-set-active",
- G_CALLBACK(manager_handle_set_active),
- NULL);
+ g_signal_connect(manager_skeleton, "handle-set-active",
+ G_CALLBACK(manager_handle_set_active), NULL);
- g_signal_connect(manager_skeleton,
- "handle-get-server-state",
- G_CALLBACK(manager_handle_get_server_state),
- NULL);
+ g_signal_connect(manager_skeleton, "handle-get-server-state",
+ G_CALLBACK(manager_handle_get_server_state), NULL);
- if (g_dbus_interface_skeleton_export(
+ ret = g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON(manager_skeleton),
connection,
"/org/tizen/NetNfcService/Manager",
- &error) == FALSE)
+ &error);
+
+ if (FALSE == ret)
{
NFC_ERR("Can not skeleton_export %s", error->message);
void net_nfc_server_manager_set_active(gboolean is_active)
{
+ bool ret;
ManagerActivationData *data;
- if (manager_skeleton == NULL)
+ if (NULL == manager_skeleton)
{
NFC_ERR("net_nfc_server_manager is not initialized");
NFC_DBG("is_active %d", is_active);
data = g_try_new0(ManagerActivationData, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
data->manager = g_object_ref(manager_skeleton);
data->is_active = is_active;
- if (net_nfc_server_controller_async_queue_push(
- manager_active_thread_func,
- data) == FALSE)
+ ret = net_nfc_server_controller_async_queue_push(manager_active_thread_func, data);
+ if (FALSE == ret)
{
NFC_ERR("can not push to controller thread");
static NetNfcGDbusNdef *ndef_skeleton = NULL;
-static void ndef_read_thread_func(gpointer user_data);
-
-static void ndef_write_thread_func(gpointer user_data);
-
-static void ndef_make_read_only_thread_func(gpointer user_data);
-
-static void ndef_format_thread_func(gpointer user_data);
-
-/* methods */
-static gboolean ndef_handle_read(NetNfcGDbusNdef *ndef,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean ndef_handle_write(NetNfcGDbusNdef *ndef,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- GVariant *arg_data,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean ndef_handle_make_read_only(NetNfcGDbusNdef *ndef,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean ndef_handle_format(NetNfcGDbusNdef *ndef,
- GDBusMethodInvocation *invocation,
- guint32 arg_handle,
- GVariant *arg_key,
- GVariant *smack_privilege,
- gpointer user_data);
-
static void ndef_read_thread_func(gpointer user_data)
{
- ReadData *data = user_data;
-
- net_nfc_target_handle_s *handle;
net_nfc_error_e result;
- data_s *read_data = NULL;
GVariant *data_variant;
+ data_s *read_data = NULL;
+ ReadData *data = user_data;
+ net_nfc_target_handle_s *handle;
g_assert(data != NULL);
g_assert(data->ndef != NULL);
handle = GUINT_TO_POINTER(data->handle);
- if (net_nfc_server_target_connected(handle) == true) {
+ if (net_nfc_server_target_connected(handle) == true)
net_nfc_controller_read_ndef(handle, &read_data, &result);
- } else {
+ else
result = NET_NFC_TARGET_IS_MOVED_AWAY;
- }
data_variant = net_nfc_util_gdbus_data_to_variant(read_data);
- net_nfc_gdbus_ndef_complete_read(data->ndef,
- data->invocation,
- (gint)result,
+ net_nfc_gdbus_ndef_complete_read(data->ndef, data->invocation, (gint)result,
data_variant);
- if (read_data) {
+ if (read_data)
+ {
net_nfc_util_free_data(read_data);
g_free(read_data);
}
static void ndef_write_thread_func(gpointer user_data)
{
+ net_nfc_error_e result;
WriteData *data = user_data;
-
net_nfc_target_handle_s *handle;
- net_nfc_error_e result;
g_assert(data != NULL);
g_assert(data->ndef != NULL);
handle = GUINT_TO_POINTER(data->handle);
- if (net_nfc_server_target_connected(handle) == true) {
+ if (net_nfc_server_target_connected(handle) == true)
net_nfc_controller_write_ndef(handle, &data->data, &result);
- } else {
+ else
result = NET_NFC_TARGET_IS_MOVED_AWAY;
- }
- net_nfc_gdbus_ndef_complete_write(data->ndef,
- data->invocation,
- (gint)result);
+ net_nfc_gdbus_ndef_complete_write(data->ndef, data->invocation, (gint)result);
net_nfc_util_free_data(&data->data);
static void ndef_make_read_only_thread_func(gpointer user_data)
{
- MakeReadOnlyData *data = user_data;
-
- net_nfc_target_handle_s *handle;
net_nfc_error_e result;
+ net_nfc_target_handle_s *handle;
+ MakeReadOnlyData *data = user_data;
g_assert(data != NULL);
g_assert(data->ndef != NULL);
handle = GUINT_TO_POINTER(data->handle);
- if (net_nfc_server_target_connected(handle) == true) {
+ if (net_nfc_server_target_connected(handle) == true)
net_nfc_controller_make_read_only_ndef(handle, &result);
- } else {
+ else
result = NET_NFC_TARGET_IS_MOVED_AWAY;
- }
- net_nfc_gdbus_ndef_complete_make_read_only(data->ndef,
- data->invocation,
- (gint)result);
+ net_nfc_gdbus_ndef_complete_make_read_only(data->ndef, data->invocation, (gint)result);
g_object_unref(data->invocation);
g_object_unref(data->ndef);
static void ndef_format_thread_func(gpointer user_data)
{
+ net_nfc_error_e result;
FormatData *data = user_data;
-
net_nfc_target_handle_s *handle;
- net_nfc_error_e result;
g_assert(data != NULL);
g_assert(data->ndef != NULL);
handle = GUINT_TO_POINTER(data->handle);
- if (net_nfc_server_target_connected(handle) == true) {
+ if (net_nfc_server_target_connected(handle) == true)
net_nfc_controller_format_ndef(handle, &data->key, &result);
- } else {
+ else
result = NET_NFC_TARGET_IS_MOVED_AWAY;
- }
- net_nfc_gdbus_ndef_complete_format(data->ndef,
- data->invocation,
- (gint)result);
+ net_nfc_gdbus_ndef_complete_format(data->ndef, data->invocation, (gint)result);
net_nfc_util_free_data(&data->key);
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
ReadData *data;
gboolean result;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::tag",
- "r") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::tag", "r");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_new0(ReadData, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->invocation = g_object_ref(invocation);
data->handle = arg_handle;
- result = net_nfc_server_controller_async_queue_push(
- ndef_read_thread_func,
- data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(ndef_read_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Ndef.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
WriteData *data;
gboolean result;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::tag",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::tag", "w");
+
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_new0(WriteData, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
- result = net_nfc_server_controller_async_queue_push(
- ndef_write_thread_func,
- data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(ndef_write_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Ndef.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
- MakeReadOnlyData *data;
+ bool ret;
gboolean result;
+ MakeReadOnlyData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::tag",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::tag", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_new0(MakeReadOnlyData, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->invocation = g_object_ref(invocation);
data->handle = arg_handle;
- result = net_nfc_server_controller_async_queue_push(
- ndef_make_read_only_thread_func,
+ result = net_nfc_server_controller_async_queue_push(ndef_make_read_only_thread_func,
data);
- if (result == FALSE)
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Ndef.ThreadError",
GVariant *smack_privilege,
gpointer user_data)
{
- FormatData *data;
+ bool ret;
gboolean result;
+ FormatData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::tag",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::tag", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_new0(FormatData, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->handle = arg_handle;
net_nfc_util_gdbus_variant_to_data_s(arg_key, &data->key);
- result = net_nfc_server_controller_async_queue_push(
- ndef_format_thread_func,
- data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(ndef_format_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Ndef.ThreadError",
ndef_skeleton = net_nfc_gdbus_ndef_skeleton_new();
- g_signal_connect(ndef_skeleton,
- "handle-read",
- G_CALLBACK(ndef_handle_read),
- NULL);
-
- g_signal_connect(ndef_skeleton,
- "handle-write",
- G_CALLBACK(ndef_handle_write),
- NULL);
-
- g_signal_connect(ndef_skeleton,
- "handle-make-read-only",
- G_CALLBACK(ndef_handle_make_read_only),
- NULL);
-
- g_signal_connect(ndef_skeleton,
- "handle-format",
- G_CALLBACK(ndef_handle_format),
- NULL);
-
- result = g_dbus_interface_skeleton_export(
- G_DBUS_INTERFACE_SKELETON(ndef_skeleton),
- connection,
- "/org/tizen/NetNfcService/Ndef",
- &error);
- if (result == FALSE)
+ g_signal_connect(ndef_skeleton, "handle-read", G_CALLBACK(ndef_handle_read), NULL);
+
+ g_signal_connect(ndef_skeleton, "handle-write", G_CALLBACK(ndef_handle_write), NULL);
+
+ g_signal_connect(ndef_skeleton, "handle-make-read-only",
+ G_CALLBACK(ndef_handle_make_read_only), NULL);
+
+ g_signal_connect(ndef_skeleton, "handle-format",
+ G_CALLBACK(ndef_handle_format), NULL);
+
+ result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(ndef_skeleton),
+ connection, "/org/tizen/NetNfcService/Ndef", &error);
+ if (FALSE == result)
{
g_error_free(error);
data_s data;
};
-static void p2p_send_data_thread_func(gpointer user_data);
-
-static gboolean p2p_handle_send(NetNfcGDbusP2p *p2p,
- GDBusMethodInvocation *invocation,
- gint32 arg_type,
- GVariant *arg_data,
- guint32 handle,
- GVariant *smack_privilege,
- gpointer user_data);
-
static NetNfcGDbusP2p *p2p_skeleton = NULL;
static void p2p_send_data_thread_func(gpointer user_data)
{
- P2pSendData *p2p_data = (P2pSendData *)user_data;
net_nfc_error_e result;
net_nfc_target_handle_s *handle;
+ P2pSendData *p2p_data = user_data;
g_assert(p2p_data != NULL);
g_assert(p2p_data->p2p != NULL);
&p2p_data->data, -1, p2p_data);
if (result != NET_NFC_OK)
{
- net_nfc_gdbus_p2p_complete_send(p2p_data->p2p,
- p2p_data->invocation,
- (gint)result);
+ net_nfc_gdbus_p2p_complete_send(p2p_data->p2p, p2p_data->invocation, (gint)result);
net_nfc_util_free_data(&p2p_data->data);
GVariant *smack_privilege,
gpointer user_data)
{
+ bool ret;
gboolean result;
P2pSendData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_new0(P2pSendData, 1);
- if(data == NULL)
+ if(NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->p2p_handle = handle;
net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->data);
- result = net_nfc_server_controller_async_queue_push(
- p2p_send_data_thread_func, data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(p2p_send_data_thread_func, data);
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.P2p.ThreadError",
p2p_skeleton = net_nfc_gdbus_p2p_skeleton_new();
- g_signal_connect(p2p_skeleton,
- "handle-send",
- G_CALLBACK(p2p_handle_send),
- NULL);
-
- result = g_dbus_interface_skeleton_export(
- G_DBUS_INTERFACE_SKELETON(p2p_skeleton),
- connection,
- "/org/tizen/NetNfcService/P2p",
- &error);
- if (result == FALSE)
+ g_signal_connect(p2p_skeleton, "handle-send", G_CALLBACK(p2p_handle_send), NULL);
+
+ result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(p2p_skeleton),
+ connection, "/org/tizen/NetNfcService/P2p", &error);
+ if (FALSE == result)
{
g_error_free(error);
net_nfc_server_free_target_info();
if (p2p_skeleton != NULL)
- {
net_nfc_gdbus_p2p_emit_detached(p2p_skeleton);
- }
}
void net_nfc_server_p2p_discovered(net_nfc_target_handle_s *handle)
{
NFC_INFO("====== p2p target discovered ======");
- if (p2p_skeleton == NULL)
+ if (NULL == p2p_skeleton)
{
NFC_ERR("p2p_skeleton is not initialized");
return;
}
- net_nfc_gdbus_p2p_emit_discovered(p2p_skeleton,
- GPOINTER_TO_UINT(handle));
+ net_nfc_gdbus_p2p_emit_discovered(p2p_skeleton, GPOINTER_TO_UINT(handle));
}
void net_nfc_server_p2p_received(data_s *user_data)
{
GVariant *arg_data;
- if (p2p_skeleton == NULL)
+ if (NULL == p2p_skeleton)
{
NFC_ERR("p2p_skeleton is not initialized");
net_nfc_gdbus_p2p_emit_received(p2p_skeleton, arg_data);
}
-void net_nfc_server_p2p_data_sent(net_nfc_error_e result,
- gpointer user_data)
+void net_nfc_server_p2p_data_sent(net_nfc_error_e result, gpointer user_data)
{
- P2pSendData *data = (P2pSendData *)user_data;
+ P2pSendData *data = user_data;
g_assert(data != NULL);
g_assert(data->p2p != NULL);
g_assert(data->invocation != NULL);
- net_nfc_gdbus_p2p_complete_send(data->p2p,
- data->invocation,
- (gint)result);
+ net_nfc_gdbus_p2p_complete_send(data->p2p, data->invocation, (gint)result);
net_nfc_util_free_data(&data->data);
data_s *ac_data,
void *user_param)
{
- HandoverRequestData *handover_data = (HandoverRequestData *)user_param;
+ HandoverRequestData *handover_data = user_param;
g_assert(handover_data != NULL);
g_assert(handover_data->invocation != NULL);
}
static net_nfc_error_e _net_nfc_server_handover_convert_ndef_message_to_data(
- ndef_message_s *msg,
- data_s *data)
+ ndef_message_s *msg, data_s *data)
{
- net_nfc_error_e result;
uint32_t length;
+ net_nfc_error_e result;
- if (msg == NULL || data == NULL)
- {
- return NET_NFC_INVALID_PARAM;
- }
+ RETV_IF(NULL == msg, NET_NFC_INVALID_PARAM);
+ RETV_IF(NULL == data, NET_NFC_INVALID_PARAM);
length = net_nfc_util_get_ndef_message_length(msg);
if (length > 0)
ndef_record_s *aux_data,
void *user_param)
{
- net_nfc_server_handover_create_config_context_t *context =
- (net_nfc_server_handover_create_config_context_t *)user_param;
+ net_nfc_server_handover_create_config_context_t *context = user_param;
/* append record to ndef message */
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
ndef_record_s *record;
/* FIXME : copy record and append */
- net_nfc_util_create_record(carrier->TNF,
- &carrier->type_s,
- &carrier->id_s,
- &carrier->payload_s,
- &record);
-
- if ((result = net_nfc_util_append_carrier_config_record(
- context->ndef_message,
- record,
- cps)) == NET_NFC_OK)
+ net_nfc_util_create_record(carrier->TNF, &carrier->type_s, &carrier->id_s,
+ &carrier->payload_s, &record);
+
+ result = net_nfc_util_append_carrier_config_record(context->ndef_message,
+ record, cps);
+
+ if (NET_NFC_OK == result)
{
NFC_DBG("net_nfc_util_append_carrier_config_record success");
}
net_nfc_util_free_record(record);
}
- g_idle_add(
- (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_to_next,
+ g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_to_next,
(gpointer)context);
}
ndef_record_s *aux_data,
void *user_param)
{
- net_nfc_server_handover_create_config_context_t *context =
- (net_nfc_server_handover_create_config_context_t *)user_param;
+ net_nfc_server_handover_create_config_context_t *context = user_param;
/* append record to ndef message */
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
ndef_record_s *record;
- net_nfc_util_create_record(carrier->TNF,
- &carrier->type_s,
- &carrier->id_s,
- &carrier->payload_s,
- &record);
+ net_nfc_util_create_record(carrier->TNF, &carrier->type_s, &carrier->id_s,
+ &carrier->payload_s, &record);
- if ((result = net_nfc_util_append_carrier_config_record(
- context->ndef_message,
- record,
- cps)) == NET_NFC_OK)
+ result = net_nfc_util_append_carrier_config_record(context->ndef_message,
+ record, cps);
+ if (NET_NFC_OK == result)
{
- NFC_DBG("net_nfc_util_append_carrier"
- "_config_record success");
+ NFC_DBG("net_nfc_util_append_carrier_config_record success");
}
else
{
- NFC_ERR("net_nfc_util_append_carrier"
- "_config_record failed [%d]",
- result);
+ NFC_ERR("net_nfc_util_append_carrier_config_record failed [%d]", result);
net_nfc_util_free_record(record);
}
- g_idle_add(
- (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_to_next,
+ g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_to_next,
(gpointer)context);
}
data_s *data,
void *user_param)
{
- net_nfc_server_handover_process_config_context_t *context =
- (net_nfc_server_handover_process_config_context_t *)user_param;
+ net_nfc_server_handover_process_config_context_t *context = user_param;
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
if (context->cb != NULL)
- {
context->cb(result, type, data, context->user_param);
- }
}
else
{
- NFC_ERR("_handover_bt_process_carrier_record failed [%d]",
- result);
+ NFC_ERR("_handover_bt_process_carrier_record failed [%d]", result);
}
_net_nfc_util_free_mem(context);
data_s *data,
void *user_param)
{
-
- net_nfc_server_handover_process_config_context_t *context =
- (net_nfc_server_handover_process_config_context_t *)user_param;
+ net_nfc_server_handover_process_config_context_t *context = user_param;
if(context)
{
if (context->cb != NULL)
- {
context->cb(result, type, data, context->user_param);
- }
else
NFC_ERR("Invalid Callback");
LOGD("[%s] START", __func__);
- if (request == NULL || record == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == request, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == record, NET_NFC_NULL_PARAMETER);
*record = NULL;
- if ((result = net_nfc_util_get_alternative_carrier_record_count(
- request,
- &carrier_count)) == NET_NFC_OK)
+ result = net_nfc_util_get_alternative_carrier_record_count(request, &carrier_count);
+ if (NET_NFC_OK == result)
{
int idx, priority;
net_nfc_conn_handover_carrier_type_e carrier_type =
/* check each carrier record and create matched record */
for (idx = 0; idx < carrier_count; idx++)
{
- if ((net_nfc_util_get_alternative_carrier_type(
- request,
- idx,
- &carrier_type)== NET_NFC_OK)
- && (carrier_type == priority))
+ result = net_nfc_util_get_alternative_carrier_type(request, idx,
+ &carrier_type);
+
+ if ((NET_NFC_OK == result) && (carrier_type == priority))
{
NFC_DBG("selected carrier type = [%d]", carrier_type);
net_nfc_util_get_carrier_config_record(request, idx, record);
}
else
{
- NFC_ERR("net_nfc_util_get_alternative_carrier"
- "_record_count failed");
+ NFC_ERR("net_nfc_util_get_alternative_carrier_record_count failed");
}
LOGD("[%s] END", __func__);
}
static net_nfc_error_e _net_nfc_server_handover_create_requester_from_rawdata(
- ndef_message_s **requestor,
- data_s *data)
+ ndef_message_s **requestor, data_s *data)
{
net_nfc_error_e result;
- if (requestor == NULL)
+ if (NULL == requestor)
return NET_NFC_NULL_PARAMETER;
*requestor = NULL;
result = net_nfc_util_create_ndef_message(requestor);
if (result == NET_NFC_OK)
{
- result = net_nfc_util_convert_rawdata_to_ndef_message(data,
- *requestor);
+ result = net_nfc_util_convert_rawdata_to_ndef_message(data, *requestor);
if (result == NET_NFC_OK)
{
- if (_net_nfc_server_handover_check_hr_record_validation(
- *requestor) == true)
+ if (_net_nfc_server_handover_check_hr_record_validation(*requestor) == true)
{
result = NET_NFC_OK;
}
else
{
- NFC_ERR("record is not valid or"
- " is not available");
+ NFC_ERR("record is not valid or is not available");
net_nfc_util_free_ndef_message(*requestor);
result = NET_NFC_INVALID_PARAM;
}
}
else
{
- NFC_ERR("_net_nfc_ndef_rawdata_to_ndef"
- "failed [%d]",result);
+ NFC_ERR("_net_nfc_ndef_rawdata_to_ndef failed [%d]",result);
}
} else {
- NFC_ERR("net_nfc_util_create_ndef_message failed [%d]",
- result);
+ NFC_ERR("net_nfc_util_create_ndef_message failed [%d]", result);
}
return result;
{
net_nfc_error_e result;
- if (selector == NULL)
+ if (NULL == selector)
return NET_NFC_NULL_PARAMETER;
*selector = NULL;
- if ((result = net_nfc_util_create_ndef_message(selector))
- == NET_NFC_OK)
+ if ((result = net_nfc_util_create_ndef_message(selector)) == NET_NFC_OK)
{
- if ((result = net_nfc_util_convert_rawdata_to_ndef_message(data,
- *selector)) == NET_NFC_OK)
+ result = net_nfc_util_convert_rawdata_to_ndef_message(data, *selector);
+ if (NET_NFC_OK == result)
{
-
/* if record is not Hs record, then */
- if (_net_nfc_server_handover_check_hs_record_validation(
- *selector) == true)
+ if (_net_nfc_server_handover_check_hs_record_validation(*selector) == true)
{
result = NET_NFC_OK;
}
else
{
- NFC_ERR("record is not valid or is "
- "not available");
+ NFC_ERR("record is not valid or is not available");
net_nfc_util_free_ndef_message(*selector);
result = NET_NFC_INVALID_PARAM;
}
}
else
{
- NFC_ERR("_net_nfc_ndef_rawdata_to_ndef"
- " failed [%d]",result);
+ NFC_ERR("_net_nfc_ndef_rawdata_to_ndef failed [%d]",result);
}
}
else
{
- NFC_ERR("_net_nfc_util_create_ndef_message"
- " failed [%d]",result);
+ NFC_ERR("_net_nfc_util_create_ndef_message failed [%d]",result);
}
return result;
static bool _net_nfc_server_handover_check_hr_record_validation(
ndef_message_s *message)
{
- unsigned int count;
ndef_record_s *rec;
+ unsigned int count;
+ net_nfc_error_e ret;
LOGD("[%s] START", __func__);
- if (message == NULL)
+ if (NULL == message)
return false;
rec = (ndef_record_s *)message->records;
- if (memcmp(rec->type_s.buffer, CH_REQ_RECORD_TYPE,
- rec->type_s.length) != 0)
+ if (memcmp(rec->type_s.buffer, CH_REQ_RECORD_TYPE, rec->type_s.length) != 0)
{
- NFC_ERR("This is not connection handover"
- " request message");
+ NFC_ERR("This is not connection handover request message");
goto ERROR;
}
goto ERROR;
}
- if (net_nfc_util_get_alternative_carrier_record_count(message, &count)
- != NET_NFC_OK || count == 0)
+ ret = net_nfc_util_get_alternative_carrier_record_count(message, &count);
+ if (ret != NET_NFC_OK || 0 == count)
{
NFC_ERR("there is no carrier reference");
goto ERROR;
static bool _net_nfc_server_handover_check_hs_record_validation(
ndef_message_s *message)
{
- unsigned int count;
ndef_record_s *rec;
+ unsigned int count;
+ net_nfc_error_e ret;
LOGD("[%s] START", __func__);
- if (message == NULL)
+ if (NULL == message)
return false;
rec = (ndef_record_s *)message->records;
- if (memcmp(rec->type_s.buffer, CH_SEL_RECORD_TYPE,
- rec->type_s.length) != 0)
+ if (memcmp(rec->type_s.buffer, CH_SEL_RECORD_TYPE, rec->type_s.length) != 0)
{
- NFC_ERR("This is not connection handover"
- " request message");
+ NFC_ERR("This is not connection handover request message");
goto ERROR;
}
- if (net_nfc_util_get_alternative_carrier_record_count(
- message,&count)!= NET_NFC_OK || count == 0)
+ ret = net_nfc_util_get_alternative_carrier_record_count(message,&count);
+ if (ret != NET_NFC_OK || 0 == count)
{
NFC_ERR("there is no carrrier reference");
goto ERROR;
/* check version */
if (rec->payload_s.buffer[0] != CH_VERSION)
{
- NFC_ERR("connection handover version"
- " is not matched");
+ NFC_ERR("connection handover version is not matched");
goto ERROR;
}
{
LOGD("[%s:%d] START", __func__, __LINE__);
- if (context == NULL)
- {
- return 0;
- }
+ RETV_IF(NULL == context, 0);
if (context->cb != NULL)
- {
- context->cb(NET_NFC_OK, context->ndef_message,
- context->user_param);
- }
+ context->cb(NET_NFC_OK, context->ndef_message, context->user_param);
if (context->ndef_message != NULL)
- {
net_nfc_util_free_ndef_message(context->ndef_message);
- }
_net_nfc_util_free_mem(context);
if (context->type == NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN)
{
if (context->current_type < NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN)
- {
context->current_type++;
- }
}
else
{
context->current_type = NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN;
}
- g_idle_add(
- (GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
+ g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
(gpointer)context);
}
else
{
NFC_ERR("context->result is error [%d]", context->result);
- g_idle_add(
- (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
+ g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
(gpointer)context);
}
case NET_NFC_CONN_HANDOVER_CARRIER_BT :
NFC_DBG("[NET_NFC_CONN_HANDOVER_CARRIER_BT]");
net_nfc_server_handover_bt_get_carrier_record(
- _net_nfc_server_handover_bt_get_carrier_record_cb,
- context);
+ _net_nfc_server_handover_bt_get_carrier_record_cb, context);
break;
case NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS :
context->ndef_message->records->type_s.length)==0)
{
result = net_nfc_server_handover_bss_wfd_get_carrier_record(
- _net_nfc_server_handover_bss_get_carrier_record_cb,
- context);
+ _net_nfc_server_handover_bss_get_carrier_record_cb, context);
}
else
#endif
{
result = net_nfc_server_handover_bss_get_carrier_record(
- _net_nfc_server_handover_bss_get_carrier_record_cb,
- context);
+ _net_nfc_server_handover_bss_get_carrier_record_cb, context);
}
NFC_DBG("[%d]",result);
break;
case NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN :
NFC_DBG("[NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN]");
- g_idle_add(
- (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
+ g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
(gpointer)context);
break;
default :
NFC_DBG("[unknown : %d]", context->current_type);
- g_idle_add(
- (GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
+ g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_carrier_configs_step,
(gpointer)context);
break;
}
static net_nfc_error_e
_net_nfc_server_handover_create_requester_carrier_configs(
- net_nfc_conn_handover_carrier_type_e type,
- void *cb,
- void *user_param)
+ net_nfc_conn_handover_carrier_type_e type, void *cb, void *user_param)
{
net_nfc_error_e result = NET_NFC_OK;
net_nfc_server_handover_create_config_context_t *context = NULL;
{
context->type = type;
if (type == NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN)
- {
context->current_type = NET_NFC_CONN_HANDOVER_CARRIER_BT;
- }
else
context->current_type = context->type;
context->cb = cb;
context->user_param = user_param;
- net_nfc_util_create_handover_request_message(
- &context->ndef_message);
+ net_nfc_util_create_handover_request_message(&context->ndef_message);
/* append carrier record */
- g_idle_add(
- (GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
+ g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
(gpointer)context);
}
else
static net_nfc_error_e
_net_nfc_server_handover_create_selector_carrier_configs(
- net_nfc_conn_handover_carrier_type_e type,
- void *cb,
- void *user_param)
+ net_nfc_conn_handover_carrier_type_e type, void *cb, void *user_param)
{
net_nfc_error_e result = NET_NFC_OK;
net_nfc_server_handover_create_config_context_t *context = NULL;
context->cb = cb;
context->user_param = user_param;
- net_nfc_util_create_handover_select_message(
- &context->ndef_message);
+ net_nfc_util_create_handover_select_message(&context->ndef_message);
/* append carrier record */
- g_idle_add(
- (GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
+ g_idle_add((GSourceFunc)_net_nfc_server_handover_iterate_create_carrier_configs,
(gpointer)context);
}
else
{
net_nfc_conn_handover_carrier_type_e type;
- net_nfc_util_get_alternative_carrier_type_from_record(
- carrier,
- &type);
+ net_nfc_util_get_alternative_carrier_type_from_record(carrier, &type);
context->type = type;
context->user_param = user_param;
{
case NET_NFC_CONN_HANDOVER_CARRIER_BT :
NFC_DBG("[NET_NFC_CONN_HANDOVER_CARRIER_BT]");
- net_nfc_server_handover_bt_process_carrier_record(
- carrier,
- _net_nfc_server_handover_bt_process_carrier_record_cb,
- context);
+ net_nfc_server_handover_bt_process_carrier_record(carrier,
+ _net_nfc_server_handover_bt_process_carrier_record_cb, context);
break;
case NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS :
NFC_DBG("[NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS]");
- net_nfc_server_handover_bss_process_carrier_record(
- carrier,
- _net_nfc_server_handover_bss_process_carrier_record_cb,
- context);
+ net_nfc_server_handover_bss_process_carrier_record(carrier,
+ _net_nfc_server_handover_bss_process_carrier_record_cb, context);
break;
case NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN :
net_nfc_conn_handover_carrier_type_e *type,
ndef_record_s **record)
{
- net_nfc_error_e result;
uint32_t count;
+ net_nfc_error_e result;
*record = NULL;
*type = NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN;
/* get requester message */
- if ((result = net_nfc_util_get_alternative_carrier_record_count(request,
- &count)) == NET_NFC_OK)
+ result = net_nfc_util_get_alternative_carrier_record_count(request, &count);
+ if (NET_NFC_OK == result)
{
- if (1/* power state */ || count == 1)
+ if (1/* power state */ || 1 == count)
{
ndef_record_s *temp;
/* fill alternative carrier information */
- if ((result =
- net_nfc_server_handover_get_carrier_record_by_priority_order(
- request,
- &temp)) == NET_NFC_OK)
+ result = net_nfc_server_handover_get_carrier_record_by_priority_order(
+ request, &temp);
+ if (NET_NFC_OK == result)
{
- if ((result =
- net_nfc_util_get_alternative_carrier_type_from_record(
- temp,
- type)) == NET_NFC_OK)
+ result = net_nfc_util_get_alternative_carrier_type_from_record(temp, type);
+ if (NET_NFC_OK == result)
{
- net_nfc_util_create_record(temp->TNF,
- &temp->type_s, &temp->id_s,
- &temp->payload_s,
- record);
+ net_nfc_util_create_record(temp->TNF, &temp->type_s, &temp->id_s,
+ &temp->payload_s, record);
}
else
{
}
else
{
- NFC_ERR("_handover_get_carrier_record"
- "_by_priority_order failed [%d]", result);
+ NFC_ERR("_handover_get_carrier_record_by_priority_order failed [%d]", result);
}
}
else /* low power && count > 1 */
}
else
{
- NFC_ERR("net_nfc_util_get_alternative_carrier_record_count "
- "failed [%d]", result);
+ NFC_ERR("net_nfc_util_get_alternative_carrier_record_count failed [%d]", result);
}
return result;
{
net_nfc_handover_context_t *context = user_param;
+ RET_IF(NULL == context);
+
NFC_DBG("_net_nfc_server_handover_server_create_carrier_config_cb result [%d]",
result);
- if (context == NULL)
- {
- return;
- }
-
context->result = result;
- if (result == NET_NFC_OK) {
+ if (NET_NFC_OK == result)
+ {
result = _net_nfc_server_handover_convert_ndef_message_to_data(
- selector,
- &context->data);
+ selector, &context->data);
NFC_DBG("selector message created, length [%d]", context->data.length);
}
else
{
- NFC_ERR("_net_nfc_server_handover_create_selector_msg failed [%d]",
- result);
+ NFC_ERR("_net_nfc_server_handover_create_selector_msg failed [%d]", result);
context->state = NET_NFC_MESSAGE_LLCP_ERROR;
}
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = (net_nfc_handover_context_t *)user_param;
NFC_DBG("_net_nfc_server_handover_server_process_carrier_record_cb result [%d]",
result);
context->result = result;
- if (result == NET_NFC_OK)
- {
+ if (NET_NFC_OK == result)
context->state = NET_NFC_LLCP_STEP_04;
- }
else
- {
context->state = NET_NFC_MESSAGE_LLCP_ERROR;
- }
context->data.length = data->length;
_net_nfc_util_alloc_mem(context->data.buffer, context->data.length);
{
net_nfc_error_e result;
- if (context == NULL)
- {
- return;
- }
+ RET_IF(NULL == context);
switch (context->state)
{
NFC_DBG("NET_NFC_LLCP_STEP_02");
result = _net_nfc_server_handover_create_selector_carrier_configs(
- context->type,
- _net_nfc_server_handover_create_carrier_configs_2_cb,
- context);
+ context->type, _net_nfc_server_handover_create_carrier_configs_2_cb, context);
if (result != NET_NFC_OK)
{
if (result != NET_NFC_OK)
{
- NFC_ERR("net_nfc_server_handover_process_carrier_record"
- "failed [%d]",result);
+ NFC_ERR("net_nfc_server_handover_process_carrier_record failed [%d]",result);
}
break;
/* response select message */
// TODO: context->handle may is not valid type. we should find a right function or parameter
result = net_nfc_server_snep_server_send_get_response(
- (net_nfc_snep_handle_h)context->handle,
- &context->data);
+ (net_nfc_snep_handle_h)context->handle, &context->data);
break;
case NET_NFC_STATE_ERROR :
net_nfc_error_e result;
ndef_message_s *request;
- NFC_DBG("type [%d], data [%p], user_param [%p]", type, data, user_param);
+ RETV_IF(NULL == data, false);
+ RETV_IF(NULL == data->buffer, false);
- if (data == NULL || data->buffer == NULL)
- {
- /* restart */
- return false;
- }
+ NFC_DBG("type [%d], data [%p], user_param [%p]", type, data, user_param);
/* TODO : send select response to requester */
result = _net_nfc_server_handover_create_requester_from_rawdata(&request, data);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
- net_nfc_conn_handover_carrier_type_e type;
ndef_record_s *record;
+ net_nfc_conn_handover_carrier_type_e type;
- if (_net_nfc_server_handover_select_carrier_record(
- request,
- &type,
- &record) == NET_NFC_OK)
+ result = _net_nfc_server_handover_select_carrier_record(request, &type, &record);
+ if (NET_NFC_OK == result)
{
net_nfc_handover_context_t *context = NULL;
context->user_param = user_param;
context->state = NET_NFC_LLCP_STEP_02;
- net_nfc_util_create_record(record->TNF,
- &record->type_s,
- &record->id_s,
- &record->payload_s,
- &context->record);
+ net_nfc_util_create_record(record->TNF, &record->type_s, &record->id_s,
+ &record->payload_s, &context->record);
_net_nfc_server_handover_get_response_process(context);
}
NFC_ERR("it is not handover requester message, [%d]", result);
}
- return (result == NET_NFC_OK);
+ return (NET_NFC_OK == result);
}
////////////////////////////////////////////////////////////////////////////////
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = user_param;
NFC_DBG("_net_nfc_server_handover_server_process_carrier_record_cb result [%d]",
result);
context->result = result;
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
context->state = NET_NFC_LLCP_STEP_04;
else
context->state = NET_NFC_MESSAGE_LLCP_ERROR;
}
static void _net_nfc_server_handover_server_create_carrier_config_cb(
- net_nfc_error_e result,
- ndef_message_s *selector,
- void *user_param)
+ net_nfc_error_e result, ndef_message_s *selector, void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_conn_handover_carrier_type_e type;
+ net_nfc_handover_context_t *context = user_param;
+
+ RET_IF(NULL == context);
NFC_DBG("_net_nfc_server_handover_server_create_carrier_config_cb,result [%d]",
result);
- if (context == NULL)
- {
- return;
- }
-
context->result = result;
- net_nfc_conn_handover_carrier_type_e type;
-
- net_nfc_util_get_alternative_carrier_type_from_record(
- context->record,
- &type);
- if (result == NET_NFC_OK)
+ net_nfc_util_get_alternative_carrier_type_from_record(context->record, &type);
+ if (NET_NFC_OK == result)
{
result = _net_nfc_server_handover_convert_ndef_message_to_data(
- selector,
- &context->data);
+ selector, &context->data);
NFC_DBG("selector message created, length [%d]", context->data.length);
if(type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)
context->state = NET_NFC_LLCP_STEP_04;
}
else
{
- NFC_ERR("_net_nfc_server_handover_create_selector_msg"
- " failed [%d]", result);
+ NFC_ERR("_net_nfc_server_handover_create_selector_msg failed [%d]", result);
context->state = NET_NFC_MESSAGE_LLCP_ERROR;
}
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_error_e ret;
ndef_message_s *request;
+ net_nfc_handover_context_t *context = user_param;
NFC_DBG("_net_nfc_server_handover_server_recv_cb, socket [%x], result [%d]",
socket, result);
context->result = result;
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
- result = _net_nfc_server_handover_create_requester_from_rawdata(
- &request,
- data);
+ result = _net_nfc_server_handover_create_requester_from_rawdata(&request, data);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
ndef_record_s *record;
- if (_net_nfc_server_handover_select_carrier_record(
- request,
- &context->type,
- &record) == NET_NFC_OK)
+ ret = _net_nfc_server_handover_select_carrier_record(request,
+ &context->type, &record);
+
+ if (NET_NFC_OK == ret)
{
- net_nfc_util_create_record(record->TNF,
- &record->type_s, &record->id_s,
- &record->payload_s,
- &context->record);
+ net_nfc_util_create_record(record->TNF, &record->type_s, &record->id_s,
+ &record->payload_s, &context->record);
context->state = NET_NFC_LLCP_STEP_02;
}
}
else
{
- NFC_ERR("net_nfc_server_llcp_simple_receive failed [%d]",
- result);
+ NFC_ERR("net_nfc_server_llcp_simple_receive failed [%d]", result);
context->state = NET_NFC_MESSAGE_LLCP_ERROR;
}
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = user_param;
NFC_DBG("_net_nfc_server_handover_server_send_cb socket[%x], result[%d]",
socket, result);
context->result = result;
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
context->state = NET_NFC_LLCP_STEP_01;
net_nfc_util_free_data(&context->data);
}
else
{
- NFC_ERR("net_nfc_server_llcp_simple_send failed [%d]",
- result);
+ NFC_ERR("net_nfc_server_llcp_simple_send failed [%d]", result);
context->state = NET_NFC_MESSAGE_LLCP_ERROR;
}
static void _net_nfc_server_handover_server_process(
net_nfc_handover_context_t *context)
{
- if (context == NULL)
- {
- return;
- }
+ RET_IF(NULL == context);
switch (context->state)
{
NFC_DBG("NET_NFC_LLCP_STEP_01");
/* receive request message */
- net_nfc_server_llcp_simple_receive(context->handle,
- context->socket,
- _net_nfc_server_handover_server_recv_cb,
- context);
+ net_nfc_server_llcp_simple_receive(context->handle, context->socket,
+ _net_nfc_server_handover_server_recv_cb, context);
break;
case NET_NFC_LLCP_STEP_02 :
if (context->result != NET_NFC_OK)
{
NFC_ERR("_net_nfc_server_handover_create_selector"
- "_carrier_configs failed [%d]", context->result);
+ "_carrier_configs failed [%d]", context->result);
}
break;
context->record,
_net_nfc_server_handover_server_process_carrier_record_cb,
context);
+
if (context->result != NET_NFC_OK)
{
NFC_ERR("_net_nfc_server_handover_process_carrier_"
NFC_DBG("NET_NFC_LLCP_STEP_04");
/* send select message */
- net_nfc_server_llcp_simple_send(
- context->handle,
- context->socket,
- &context->data,
- _net_nfc_server_handover_server_send_cb,
- context);
+ net_nfc_server_llcp_simple_send(context->handle, context->socket, &context->data,
+ _net_nfc_server_handover_server_send_cb, context);
break;
case NET_NFC_STATE_ERROR :
NFC_DBG("NET_NFC_STATE_ERROR");
/* error, invoke callback */
- NFC_ERR("handover_server failed, [%d]",
- context->result);
+ NFC_ERR("handover_server failed, [%d]", context->result);
/* restart?? */
break;
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = user_param;
- NFC_ERR("result [%d], socket [%x], user_param [%p]",
- result, socket, user_param);
+ NFC_ERR("result [%d], socket [%x], user_param [%p]", result, socket, user_param);
- if (context == NULL)
- {
- return;
- }
+ RET_IF(NULL == context);
net_nfc_controller_llcp_socket_close(socket, &result);
data_s *data,
void *user_param)
{
- NFC_DBG("result[%d], socket[%x], user_param[%p]", result, socket, user_param);
-
net_nfc_handover_context_t *accept_context = NULL;
+ NFC_DBG("result[%d], socket[%x], user_param[%p]", result, socket, user_param);
+
_net_nfc_util_alloc_mem(accept_context, sizeof(*accept_context));
- if (accept_context == NULL)
+ if (NULL == accept_context)
{
NFC_ERR("_net_nfc_util_alloc_mem failed");
accept_context->socket = socket;
accept_context->state = NET_NFC_LLCP_STEP_01;
- result = net_nfc_server_llcp_simple_accept(
- handle,
- socket,
- _net_nfc_server_handover_server_error_cb,
- accept_context);
+ result = net_nfc_server_llcp_simple_accept(handle, socket,
+ _net_nfc_server_handover_server_error_cb, accept_context);
if (result != NET_NFC_OK)
{
- NFC_ERR("net_nfc_server_llcp_simple_accept failed, [%d]",
- result);
+ NFC_ERR("net_nfc_server_llcp_simple_accept failed, [%d]", result);
goto ERROR;
}
ERROR :
if (accept_context != NULL)
- {
_net_nfc_util_free_mem(accept_context);
- }
net_nfc_controller_llcp_socket_close(socket, &result);
net_nfc_error_e result;
/* start default handover server using snep */
- result =
- net_nfc_server_snep_default_server_register_get_response_cb(
- _net_nfc_server_handover_get_response_cb, NULL);
+ result = net_nfc_server_snep_default_server_register_get_response_cb(
+ _net_nfc_server_handover_get_response_cb, NULL);
/* start default handover server */
result = net_nfc_server_llcp_simple_server(
_net_nfc_server_handover_server_error_cb,
NULL);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
NFC_DBG("start handover server, san[%s], sap[%d]", CH_SAN, CH_SAP);
else
NFC_ERR("net_nfc_server_llcp_simple_server failed, [%d]", result);
NFC_DBG("event [%d], handle [%p], sap [%d], san [%s]", event, handle, sap, san);
- if (event == NET_NFC_LLCP_START) {
+ if (NET_NFC_LLCP_START == event)
+ {
/* start default handover server using snep */
result = net_nfc_server_snep_default_server_register_get_response_cb(
_net_nfc_server_handover_get_response_cb, NULL);
_net_nfc_server_handover_server_incomming_cb,
_net_nfc_server_handover_server_error_cb, NULL);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
NFC_DBG("start handover server, san [%s], sap [%d]", CH_SAN, CH_SAP);
else
NFC_ERR("net_nfc_service_llcp_server failed, [%d]", result);
- } else if (event == NET_NFC_LLCP_UNREGISTERED) {
+ }
+ else if (NET_NFC_LLCP_UNREGISTERED == event)
+ {
/* unregister server, do nothing */
}
}
snprintf(id, sizeof(id), "%d", getpid());
/* start default snep server */
- return net_nfc_server_llcp_register_service(id,
- CH_SAP,
- CH_SAN,
- _handover_default_activate_cb,
- NULL);
+ return net_nfc_server_llcp_register_service(id, CH_SAP, CH_SAN,
+ _handover_default_activate_cb, NULL);
}
net_nfc_error_e net_nfc_server_handover_default_server_unregister()
snprintf(id, sizeof(id), "%d", getpid());
/* start default snep server */
- return net_nfc_server_llcp_unregister_service(id,
- CH_SAP,
- CH_SAN);
+ return net_nfc_server_llcp_unregister_service(id, CH_SAP, CH_SAN);
}
////////////////////////////////////////////////////////////////////////////////
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = user_param;
- if (context == NULL)
- {
- return;
- }
+ RET_IF(NULL == context);
context->state = NET_NFC_LLCP_STEP_RETURN;
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = user_param;
NFC_DBG("_net_nfc_server_handover_server_process_carrier_record_cb, result[%d]",
result);
net_nfc_util_free_data(&context->data);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
if(context->type == NET_NFC_CONN_HANDOVER_CARRIER_WIFI_BSS)
+ {
context->state = NET_NFC_LLCP_STEP_RETURN;
+ }
else
{
net_nfc_util_alloc_data(&context->data, data->length);
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = user_param;
- if (context == NULL)
- {
- return;
- }
+ RET_IF(NULL == context);
context->result = result;
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
- ndef_message_s *selector;
ndef_record_s *record;
+ ndef_message_s *selector;
- result = net_nfc_server_handover_create_selector_from_rawdata(
- &selector,
- data);
+ result = net_nfc_server_handover_create_selector_from_rawdata(&selector, data);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
- result =
- net_nfc_server_handover_get_carrier_record_by_priority_order(
- selector,
- &record);
+ result = net_nfc_server_handover_get_carrier_record_by_priority_order(
+ selector, &record);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
- net_nfc_util_create_record(
- record->TNF,
- &record->type_s, &record->id_s,
- &record->payload_s,
- &context->record);
+ net_nfc_util_create_record(record->TNF, &record->type_s, &record->id_s,
+ &record->payload_s, &context->record);
context->state = NET_NFC_LLCP_STEP_04;
}
else
{
- NFC_ERR("_get_carrier_record_by_priority_order"
- " failed, [%d]",result);
+ NFC_ERR("_get_carrier_record_by_priority_order failed, [%d]",result);
context->state = NET_NFC_STATE_ERROR;
}
}
}
else
{
- NFC_ERR("net_nfc_server_llcp_simple_receive failed, [%d]",
- result);
+ NFC_ERR("net_nfc_server_llcp_simple_receive failed, [%d]", result);
context->state = NET_NFC_STATE_ERROR;
}
data_s *data,
void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = user_param;
- if (context == NULL)
- {
- return;
- }
+ RET_IF(NULL == context);
context->result = result;
net_nfc_util_free_data(&context->data);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
context->state = NET_NFC_LLCP_STEP_03;
}
else
{
- NFC_ERR("net_nfc_server_llcp_simple_client failed, [%d]",
- result);
+ NFC_ERR("net_nfc_server_llcp_simple_client failed, [%d]", result);
context->state = NET_NFC_STATE_ERROR;
}
}
static void _net_nfc_server_handover_client_create_carrier_configs_cb(
- net_nfc_error_e result,
- ndef_message_s *msg,
- void *user_param)
+ net_nfc_error_e result, ndef_message_s *msg, void *user_param)
{
- net_nfc_handover_context_t *context =
- (net_nfc_handover_context_t *)user_param;
+ net_nfc_handover_context_t *context = user_param;
- if (context == NULL) {
- return;
- }
+ RET_IF(NULL == context);
context->result = result;
if (msg != NULL)
{
- if ((result =
- _net_nfc_server_handover_convert_ndef_message_to_data(
- msg,
- &context->data)) == NET_NFC_OK)
+ result = _net_nfc_server_handover_convert_ndef_message_to_data(msg, &context->data);
+ if (NET_NFC_OK == result)
{
context->state = NET_NFC_LLCP_STEP_02;
}
{
net_nfc_error_e result;
- if (context == NULL)
- {
- return;
- }
+ RET_IF(NULL == context);
switch (context->state)
{
case NET_NFC_LLCP_STEP_01 :
NFC_DBG("NET_NFC_LLCP_STEP_01");
- if ((result = _net_nfc_server_handover_create_requester_carrier_configs(
+ result = _net_nfc_server_handover_create_requester_carrier_configs(
context->type,
_net_nfc_server_handover_client_create_carrier_configs_cb,
- context)) != NET_NFC_OK)
+ context);
+ if (result != NET_NFC_OK)
{
NFC_ERR("_net_nfc_server_handover_create_requester"
"_carrier_configs failed [%d]",result);
NFC_DBG("NET_NFC_LLCP_STEP_02");
/* send request */
- net_nfc_server_llcp_simple_send(
- context->handle,
- context->socket,
- &context->data,
- _net_nfc_server_handover_client_send_cb,
- context);
+ net_nfc_server_llcp_simple_send(context->handle, context->socket, &context->data,
+ _net_nfc_server_handover_client_send_cb, context);
break;
case NET_NFC_LLCP_STEP_03 :
NFC_DBG("NET_NFC_LLCP_STEP_03");
/* receive response */
- net_nfc_server_llcp_simple_receive(context->handle,
- context->socket,
- _net_nfc_server_handover_client_recv_cb,
- context);
+ net_nfc_server_llcp_simple_receive(context->handle, context->socket,
+ _net_nfc_server_handover_client_recv_cb, context);
break;
case NET_NFC_LLCP_STEP_04 :
NFC_DBG("NET_NFC_LLCP_STEP_04");
- result = net_nfc_server_handover_process_carrier_record(
- context->record,
- _net_nfc_server_handover_client_process_carrier_record_cb,
- context);
+ result = net_nfc_server_handover_process_carrier_record(context->record,
+ _net_nfc_server_handover_client_process_carrier_record_cb, context);
if (result != NET_NFC_OK)
- {
NFC_ERR("net_nfc_server_handover_process_carrier_record failed [%d]",result);
- }
break;
case NET_NFC_LLCP_STEP_05 :
NFC_DBG("NET_NFC_LLCP_STEP_05");
/* start post process */
- if (context->type == NET_NFC_CONN_HANDOVER_CARRIER_BT)
+ if (NET_NFC_CONN_HANDOVER_CARRIER_BT == context->type)
{
- net_nfc_server_handover_bt_post_process(
- &context->data,
- _net_nfc_server_handover_client_post_process_cb,
- context);
+ net_nfc_server_handover_bt_post_process(&context->data,
+ _net_nfc_server_handover_client_post_process_cb, context);
}
else
{
NFC_DBG("NET_NFC_LLCP_STEP_RETURN");
/* complete and invoke callback */
- _net_nfc_server_handover_send_response(
- context->result,
- context->type,
- &context->data,
- context->user_param);
+ _net_nfc_server_handover_send_response(context->result, context->type,
+ &context->data, context->user_param);
net_nfc_util_free_data(&context->data);
net_nfc_util_free_record(context->record);
default :
NFC_ERR("NET_NFC_STATE_ERROR");
- _net_nfc_server_handover_send_response(
- context->result,
- context->type,
- NULL,
- context->user_param);
+ _net_nfc_server_handover_send_response(context->result, context->type,
+ NULL, context->user_param);
break;
}
}
HandoverRequestData *handover_data = NULL;
handover_data = (HandoverRequestData *)user_param;
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
net_nfc_handover_context_t *context = NULL;
_net_nfc_util_alloc_mem(context, sizeof(*context));
data_s *data,
void *user_param)
{
-
- NFC_ERR("result [%d], socket [%x], user_param [%p]",
- result, socket, user_param);
+ NFC_ERR("result [%d], socket [%x], user_param [%p]", result, socket, user_param);
if (false)
{
- _net_nfc_server_handover_send_response(
- result,
- NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN,
- NULL,
- user_param);
+ _net_nfc_server_handover_send_response(result,
+ NET_NFC_CONN_HANDOVER_CARRIER_UNKNOWN, NULL, user_param);
}
net_nfc_controller_llcp_socket_close(socket, &result);
user_data);
if (result != NET_NFC_OK)
- {
- NFC_ERR("net_nfc_server_llcp_simple_client"
- " failed, [%d]",result);
- }
+ NFC_ERR("net_nfc_server_llcp_simple_client failed, [%d]",result);
return result;
}
#define NPP_NDEF_ENTRY 0x00000001
#define NPP_ACTION_CODE 0x01
-static net_nfc_error_e npp_create_message(data_s *data,
- data_s *message);
-
-/* server */
-static void npp_server_receive_cb(net_nfc_error_e result,
- net_nfc_target_handle_s *handle,
- net_nfc_llcp_socket_t socket,
- data_s *data,
- gpointer user_data);
-
-static void npp_server_process(NppData *npp_data);
-
-static void npp_listen_cb(net_nfc_error_e result, net_nfc_target_handle_s *handle,
- net_nfc_llcp_socket_t socket, data_s *data, gpointer user_data);
-
-/* client */
-static void npp_client_disconnected_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result, data_s *data, void *extra, void *user_param);
-
-static void npp_client_send_cb(net_nfc_error_e result,
- net_nfc_target_handle_s *handle,
- net_nfc_llcp_socket_t socket,
- data_s *data,
- gpointer user_data);
-
-static void npp_client_process(NppData *npp_data);
-
-static void npp_connected_cb(net_nfc_error_e result,
- net_nfc_target_handle_s *handle,
- net_nfc_llcp_socket_t socket,
- data_s *data,
- gpointer user_data);
-
static void npp_socket_error_cb(net_nfc_error_e result,
net_nfc_target_handle_s *handle,
net_nfc_llcp_socket_t socket,
data_s *data,
gpointer user_data);
-static void npp_default_server_cb(net_nfc_error_e result, data_s *data,
- gpointer user_data);
-
-static void npp_default_client_cb(net_nfc_error_e result, data_s *data,
- gpointer user_data);
-
static net_nfc_error_e npp_create_message(data_s *data, data_s *message)
{
- uint32_t length = NPP_HEADER_LEN;
net_nfc_npp_msg_t *msg;
+ uint32_t length = NPP_HEADER_LEN;
if (data != NULL)
length += NPP_ENTITY_HEADER_LEN + data->length;
data_s *data,
gpointer user_data)
{
+ uint32_t i;
+ uint32_t length;
NppData *npp_data;
-
+ uint32_t entity_count;
net_nfc_npp_msg_t *message;
net_nfc_npp_entity_t *entity;
-
data_s ndef_msg = { NULL, 0 };
- uint32_t length;
- uint32_t entity_count;
- uint32_t i;
+ RET_IF(NULL == user_data);
- npp_data = (NppData *)user_data;
-
- if (npp_data == NULL)
- return;
+ npp_data = user_data;
if (result != NET_NFC_OK)
{
return;
}
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("data is NULL");
if(npp_data->callback)
- {
- npp_data->callback(NET_NFC_INVALID_PARAM,
- NULL,
- npp_data->user_data);
- }
+ npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
g_free(npp_data);
return;
}
- if (data->buffer == NULL || data->length == 0)
+ if (NULL == data->buffer || 0 == data->length)
{
NFC_ERR("Wrong data");
if(npp_data->callback)
- {
- npp_data->callback(NET_NFC_INVALID_PARAM,
- NULL,
- npp_data->user_data);
- }
+ npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
g_free(npp_data);
return;
if (data->length < NPP_HEADER_LEN)
{
- NFC_ERR("too short data, length [%d]",
- data->length);
+ NFC_ERR("too short data, length [%d]", data->length);
/* FIXME!!! what should I do. */
if(npp_data->callback)
- {
- npp_data->callback(NET_NFC_INVALID_PARAM,
- NULL,
- npp_data->user_data);
- }
+ npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
g_free(npp_data);
return;
if (GET_MAJOR_VER(message->version) > NPP_MAJOR_VER ||
GET_MINOR_VER(message->version > NPP_MINOR_VER))
{
- NFC_ERR("not supported version, version [0x%02x]",
- message->version);
+ NFC_ERR("not supported version, version [0x%02x]", message->version);
if(npp_data->callback)
- {
- npp_data->callback(NET_NFC_NOT_SUPPORTED,
- NULL,
- npp_data->user_data);
- }
+ npp_data->callback(NET_NFC_NOT_SUPPORTED, NULL, npp_data->user_data);
g_free(npp_data);
return;
if (entity_count > NPP_NDEF_ENTRY)
{
- NFC_ERR("too many entities, [%d]",
- message->entity_count);
+ NFC_ERR("too many entities, [%d]", message->entity_count);
if(npp_data->callback)
- {
- npp_data->callback(NET_NFC_INVALID_PARAM,
- NULL,
- npp_data->user_data);
- }
+ npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
g_free(npp_data);
return;
{
entity = (message->entity + i);
- if (entity->op != NPP_ACTION_CODE) {
- NFC_ERR("not supported action code, [0x%02x]",
- entity->op);
+ if (entity->op != NPP_ACTION_CODE)
+ {
+ NFC_ERR("not supported action code, [0x%02x]", entity->op);
if(npp_data->callback)
- {
- npp_data->callback(NET_NFC_INVALID_PARAM,
- NULL,
- npp_data->user_data);
- }
+ npp_data->callback(NET_NFC_INVALID_PARAM, NULL, npp_data->user_data);
g_free(npp_data);
return;
static void npp_server_process(NppData *npp_data)
{
net_nfc_error_e result;
- if (npp_data == NULL)
- return;
+
+ RET_IF(NULL == npp_data);
/* receive request */
- result = net_nfc_server_llcp_simple_receive(npp_data->handle,
- npp_data->socket,
- npp_server_receive_cb,
- npp_data);
+ result = net_nfc_server_llcp_simple_receive(npp_data->handle, npp_data->socket,
+ npp_server_receive_cb, npp_data);
if (result != NET_NFC_OK)
{
if (npp_data->callback)
NppData *npp_data;
NppData *accept_data;
- npp_data = (NppData *)user_data;
- if (npp_data == NULL)
- return;
+ RET_IF(NULL == user_data);
+
+ npp_data = user_data;
NFC_DBG("npp_listen_cb, incoming socket [%#x], result [%d]", socket, result);
accept_data->callback = npp_data->callback;
accept_data->user_data = npp_data->user_data;
- result = net_nfc_server_llcp_simple_accept(handle,
- socket,
- npp_socket_error_cb,
+ result = net_nfc_server_llcp_simple_accept(handle, socket, npp_socket_error_cb,
accept_data);
if (result != NET_NFC_OK)
{
- NFC_ERR("%s failed",
- "net_nfc_server_llcp_simple_accept");
+ NFC_ERR("%s failed net_nfc_server_llcp_simple_accept");
if (npp_data->callback)
npp_data->callback(result, NULL, npp_data->user_data);
/* client */
static void npp_client_disconnected_cb(net_nfc_llcp_socket_t socket,
- net_nfc_error_e result,
- data_s *data,
- void *extra,
- void *user_param)
+ net_nfc_error_e result, data_s *data, void *extra, void *user_param)
{
NFC_INFO("disconnected! [%d]", result);
}
{
NppData *npp_data;
- npp_data = (NppData *)user_data;
- if (npp_data == NULL)
- return;
+ RET_IF(NULL == user_data);
+
+ npp_data = user_data;
NFC_DBG("send complete... [%d]", result);
if (npp_data->callback)
- {
npp_data->callback(result, NULL, npp_data->user_data);
- }
- net_nfc_controller_llcp_disconnect(npp_data->handle,
- npp_data->socket,
- &result,
- npp_client_disconnected_cb,
- NULL);
+ net_nfc_controller_llcp_disconnect(npp_data->handle, npp_data->socket,
+ &result, npp_client_disconnected_cb, NULL);
g_free(npp_data->data.buffer);
g_free(npp_data);
static void npp_client_process(NppData *npp_data)
{
- net_nfc_error_e result;
data_s data;
+ net_nfc_error_e result;
- if (npp_data == NULL)
- return;
+ RET_IF(NULL == npp_data);
result = npp_create_message(&npp_data->data, &data);
if (result != NET_NFC_OK)
}
/* send request */
- result = net_nfc_server_llcp_simple_send(npp_data->handle,
- npp_data->socket,
- &data,
- npp_client_send_cb,
- npp_data);
+ result = net_nfc_server_llcp_simple_send(npp_data->handle, npp_data->socket,
+ &data, npp_client_send_cb, npp_data);
if (result != NET_NFC_OK)
{
- NFC_ERR("%s failed [%d]",
- "net_nfc_server_llcp_simple_send",
- result);
+ NFC_ERR("%s failed [%d] net_nfc_server_llcp_simple_send", result);
if (npp_data->callback)
npp_data->callback(result, NULL, npp_data->user_data);
{
NppData *npp_data;
- npp_data = (NppData *)user_data;
- if (npp_data == NULL)
- return;
+ RET_IF(NULL == user_data);
+
+ npp_data = user_data;
if (result != NET_NFC_OK)
{
NFC_DBG("socket [%x], result [%d]", socket, result);
- npp_data = (NppData *)user_data;
- if (npp_data == NULL)
- return;
+ RET_IF(NULL == user_data);
+ npp_data = user_data;
if (npp_data->callback)
npp_data->callback(result, NULL, npp_data->user_data);
g_free(npp_data);
}
-static void npp_default_server_cb(net_nfc_error_e result,
- data_s *data,
+static void npp_default_server_cb(net_nfc_error_e result, data_s *data,
gpointer user_data)
{
NFC_DBG("result [%d], data [%p], user_data [%p]", result, data, user_data);
- if (data == NULL)
- {
- NFC_ERR("npp server receive failed, [%d]", result);
- return;
- }
-
- if (data->buffer == NULL)
- {
- NFC_ERR("npp server receive failed, [%d]", result);
- return;
- }
+ RET_IF(NULL == data);
+ RET_IF(NULL == data->buffer);
net_nfc_server_p2p_received(data);
net_nfc_app_util_process_ndef(data);
NFC_DBG("result [%d], data [%p], user_data [%p]", result, data, user_data);
- if (user_data == NULL)
- return;
+ RET_IF(NULL == user_data);
- npp_client_data = (NppClientStartData *)user_data;
+ npp_client_data = user_data;
net_nfc_server_p2p_data_sent(result, npp_client_data->user_data);
net_nfc_error_e net_nfc_server_npp_server(net_nfc_target_handle_s *handle,
char *san, sap_t sap, net_nfc_server_npp_callback callback, gpointer user_data)
{
- net_nfc_error_e result = NET_NFC_OK;
-
NppData *npp_data = NULL;
+ net_nfc_error_e result = NET_NFC_OK;
- if (handle == NULL)
- {
- NFC_ERR("handle is NULL");
- return FALSE;
- }
-
- if (san == NULL)
- {
- NFC_ERR("san is NULL");
- return FALSE;
- }
+ RETV_IF(NULL == san, FALSE);
+ RETV_IF(NULL == handle, FALSE);
npp_data = g_new0(NppData, 1);
npp_data->callback = callback;
npp_data->user_data = user_data;
- result = net_nfc_server_llcp_simple_server(handle,
- san,
- sap,
- npp_listen_cb,
- npp_socket_error_cb,
- npp_data);
+ result = net_nfc_server_llcp_simple_server(handle, san, sap, npp_listen_cb,
+ npp_socket_error_cb, npp_data);
if (result != NET_NFC_OK)
{
- NFC_ERR("%s failed",
- "net_nfc_server_llcp_simple_server");
+ NFC_ERR("net_nfc_server_llcp_simple_server failed");
if (npp_data->callback)
npp_data->callback(result, NULL, npp_data->user_data);
net_nfc_server_npp_callback callback,
gpointer user_data)
{
- net_nfc_error_e result = NET_NFC_OK;;
- net_nfc_llcp_config_info_s config;
-
NppData *npp_data;
+ net_nfc_llcp_config_info_s config;
+ net_nfc_error_e result = NET_NFC_OK;;
- if (handle == NULL)
- {
- NFC_ERR("handle is NULL");
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
- if(net_nfc_controller_llcp_get_remote_config(handle,
- &config,
- &result) == false)
+ if(net_nfc_controller_llcp_get_remote_config(handle, &config, &result) == false)
{
- NFC_ERR("%s failed [%d]",
- "net_nfc_controller_llcp_get_remote_config",
- result);
-
+ NFC_ERR("net_nfc_controller_llcp_get_remote_config failed [%d]", result);
return result;
}
- if (config.miu <
- data->length + NPP_HEADER_LEN + NPP_ENTITY_HEADER_LEN)
+ if (config.miu < data->length + NPP_HEADER_LEN + NPP_ENTITY_HEADER_LEN)
{
NFC_ERR("too large message, max [%d], request [%d]",
- config.miu - (NPP_HEADER_LEN + NPP_ENTITY_HEADER_LEN),
- data->length);
+ config.miu - (NPP_HEADER_LEN + NPP_ENTITY_HEADER_LEN), data->length);
return NET_NFC_INSUFFICIENT_STORAGE;
}
npp_data->data.buffer = g_new0(uint8_t, data->length);
npp_data->data.length = data->length;
- result = net_nfc_server_llcp_simple_client(handle,
- san,
- sap,
- npp_connected_cb,
- npp_socket_error_cb,
- npp_data);
+ result = net_nfc_server_llcp_simple_client(handle, san, sap,
+ npp_connected_cb, npp_socket_error_cb, npp_data);
if (result != NET_NFC_OK)
{
- NFC_ERR("%s failed",
- "net_nfc_server_llcp_simple_client");
+ NFC_ERR("net_nfc_server_llcp_simple_client failed");
if (npp_data->callback)
- {
- npp_data->callback(NET_NFC_UNKNOWN_ERROR,
- NULL,
- npp_data->user_data);
- }
+ npp_data->callback(NET_NFC_UNKNOWN_ERROR, NULL, npp_data->user_data);
g_free(npp_data->data.buffer);
g_free(npp_data);
net_nfc_target_handle_s *handle)
{
/* start default npp server */
- return net_nfc_server_npp_server(handle,
- NPP_SAN,
- NPP_SAP,
- npp_default_server_cb,
+ return net_nfc_server_npp_server(handle, NPP_SAN, NPP_SAP, npp_default_server_cb,
(gpointer)1234);
}
/* start default npp server */
result = net_nfc_server_npp_server(handle, (char *)san, sap,
npp_default_server_cb, user_param);
- if (result != NET_NFC_OK) {
- NFC_ERR("net_nfc_server_npp_server failed, [%d]",
- result);
- }
- } else if (event == NET_NFC_LLCP_UNREGISTERED) {
+ if (result != NET_NFC_OK)
+ NFC_ERR("net_nfc_server_npp_server failed, [%d]", result);
+
+ }
+ else if (event == NET_NFC_LLCP_UNREGISTERED)
+ {
/* unregister server, do nothing */
}
}
snprintf(id, sizeof(id), "%d", getpid());
/* start default npp server */
- return net_nfc_server_llcp_register_service(id,
- NPP_SAP,
- NPP_SAN,
- _npp_default_activate_cb,
- NULL);
+ return net_nfc_server_llcp_register_service(id, NPP_SAP, NPP_SAN,
+ _npp_default_activate_cb, NULL);
}
net_nfc_error_e net_nfc_server_npp_default_server_unregister()
snprintf(id, sizeof(id), "%d", getpid());
/* start default npp server */
- return net_nfc_server_llcp_unregister_service(id,
- NPP_SAP,
- NPP_SAN);
+ return net_nfc_server_llcp_unregister_service(id, NPP_SAP, NPP_SAN);
}
net_nfc_error_e net_nfc_server_npp_default_client_start(
net_nfc_target_handle_s *handle, data_s *data, int client, gpointer user_data)
{
- NppClientStartData *npp_client_data;
-
net_nfc_error_e result = NET_NFC_OK;
+ NppClientStartData *npp_client_data;
- if (handle == NULL)
- {
- NFC_ERR("handle is NULL");
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (data == NULL)
- {
- NFC_ERR("data is NULL");
- return NET_NFC_NULL_PARAMETER;
- }
-
- if (data->buffer == NULL)
- {
- NFC_ERR("data->buffer is NULL");
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == handle, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == data->buffer, NET_NFC_NULL_PARAMETER);
npp_client_data = g_new0(NppClientStartData, 1);
npp_client_data->client = client;
npp_client_data->user_data = user_data;
- result = net_nfc_server_npp_client(handle,
- NPP_SAN,
- NPP_SAP,
- data,
- npp_default_client_cb,
- npp_client_data);
+ result = net_nfc_server_npp_client(handle, NPP_SAN, NPP_SAP, data,
+ npp_default_client_cb, npp_client_data);
if (result != NET_NFC_OK)
{
gint mode;
};
-static void se_close_secure_element_thread_func(gpointer user_data);
-
-static void se_get_atr_thread_func(gpointer user_data);
-
-static void se_open_secure_element_thread_func(gpointer user_data);
-
-static void se_send_apdu_thread_func(gpointer user_data);
-
-static void se_set_data_thread_func(gpointer user_data);
-
-static gboolean se_handle_close_secure_element(
- NetNfcGDbusSecureElement *object,
- GDBusMethodInvocation *invocation,
- guint arg_handle,
- GVariant *smack_privilege);
-
-static gboolean se_handle_get_atr(
- NetNfcGDbusSecureElement *object,
- GDBusMethodInvocation *invocation,
- guint arg_handle,
- GVariant *smack_privilege);
-
-
-static gboolean se_handle_open_secure_element(
- NetNfcGDbusSecureElement *object,
- GDBusMethodInvocation *invocation,
- gint arg_type,
- GVariant *smack_privilege);
-
-
-static gboolean se_handle_send_apdu(
- NetNfcGDbusSecureElement *object,
- GDBusMethodInvocation *invocation,
- guint arg_handle,
- GVariant* apdudata,
- GVariant *smack_privilege);
-
-static gboolean se_handle_set(
- NetNfcGDbusSecureElement *object,
- GDBusMethodInvocation *invocation,
- gint arg_type,
- GVariant *smack_privilege);
-
-
uint8_t net_nfc_server_se_get_se_type()
{
return gdbus_se_setting.type;
static net_nfc_target_handle_s *net_nfc_server_se_open_ese()
{
- if (gdbus_ese_handle == NULL) {
+ bool ret;
+
+ if (NULL == gdbus_ese_handle)
+ {
net_nfc_error_e result = NET_NFC_OK;
net_nfc_target_handle_s *handle = NULL;
- if (net_nfc_controller_secure_element_open(
- SECURE_ELEMENT_TYPE_ESE,
- &handle, &result) == true)
+ ret = net_nfc_controller_secure_element_open(SECURE_ELEMENT_TYPE_ESE,
+ &handle, &result);
+ if (true == ret)
{
net_nfc_server_se_set_current_ese_handle(handle);
}
else
{
- NFC_ERR("net_nfc_controller_secure_element_open failed [%d]",
- result);
+ NFC_ERR("net_nfc_controller_secure_element_open failed [%d]", result);
}
}
{
net_nfc_error_e result = NET_NFC_OK;
- if (gdbus_ese_handle != NULL &&
- net_nfc_server_gdbus_is_server_busy() == false) {
- if (net_nfc_controller_secure_element_close(
- gdbus_ese_handle,
- &result) == false)
- {
+ if (gdbus_ese_handle != NULL && net_nfc_server_gdbus_is_server_busy() == false)
+ {
+ if (net_nfc_controller_secure_element_close(gdbus_ese_handle, &result) == false)
net_nfc_controller_exception_handler();
- }
+
net_nfc_server_se_set_current_ese_handle(NULL);
- }
+ }
return result;
}
net_nfc_error_e result;
/*turn off ESE*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_ESE,
- SECURE_ELEMENT_OFF_MODE,
- &result);
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+ SECURE_ELEMENT_OFF_MODE, &result);
/*turn on UICC*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_UICC,
- SECURE_ELEMENT_VIRTUAL_MODE,
- &result);
- if (result == NET_NFC_OK) {
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_VIRTUAL_MODE, &result);
+
+ if (NET_NFC_OK == result)
+ {
NFC_INFO("card emulation changed to SECURE_ELEMENT_TYPE_UICC");
net_nfc_server_se_set_se_type(SECURE_ELEMENT_TYPE_UICC);
net_nfc_server_se_set_se_mode(SECURE_ELEMENT_VIRTUAL_MODE);
- if (vconf_set_int(VCONFKEY_NFC_SE_TYPE,
- VCONFKEY_NFC_SE_TYPE_UICC) < 0) {
+ if (vconf_set_int(VCONFKEY_NFC_SE_TYPE, VCONFKEY_NFC_SE_TYPE_UICC) < 0)
NFC_ERR("vconf_set_int failed");
- }
- } else {
- NFC_ERR("net_nfc_controller_set_secure_element_mode failed, [%d]",
- result);
+ }
+ else
+ {
+ NFC_ERR("net_nfc_controller_set_secure_element_mode failed, [%d]", result);
}
}
char **cpList;
cpList = tel_get_cp_name_list();
- if (cpList != NULL) {
+ if (cpList != NULL)
+ {
gdbus_uicc_handle = tel_init(cpList[0]);
- if (gdbus_uicc_handle != NULL) {
- } else {
+ if (NULL == gdbus_uicc_handle)
NFC_ERR("tel_init() failed");
- }
- } else {
+
+ }
+ else
+ {
NFC_ERR("tel_get_cp_name_list() failed");
}
}
static void _se_uicc_status_noti_cb(TapiHandle *handle,
- const char *noti_id,
- void *data,
- void *user_data)
+ const char *noti_id, void *data, void *user_data)
{
- TelSimCardStatus_t *status = (TelSimCardStatus_t *)data;
+ TelSimCardStatus_t *status = data;
NFC_DBG("_se_uicc_status_noti_cb");
- switch (*status) {
+ switch (*status)
+ {
case TAPI_SIM_STATUS_SIM_INIT_COMPLETED :
gdbus_uicc_ready = SE_UICC_READY;
_se_uicc_prepare();
if (gdbus_se_setting.busy == true &&
- net_nfc_server_se_get_se_type() == SECURE_ELEMENT_TYPE_UICC) {
-
+ net_nfc_server_se_get_se_type() == SECURE_ELEMENT_TYPE_UICC)
+ {
gdbus_se_setting.busy = false;
_se_uicc_enable_card_emulation();
NFC_DBG("TAPI_SIM_STATUS_CARD_REMOVED");
gdbus_uicc_ready = SE_UICC_UNAVAILABLE;
- if (net_nfc_server_se_get_se_type() == SECURE_ELEMENT_TYPE_UICC) {
+ if (net_nfc_server_se_get_se_type() == SECURE_ELEMENT_TYPE_UICC)
+ {
net_nfc_error_e result;
/*turn off UICC*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_UICC,
- SECURE_ELEMENT_OFF_MODE,
- &result);
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_OFF_MODE, &result);
net_nfc_server_se_set_se_type(SECURE_ELEMENT_TYPE_INVALID);
net_nfc_server_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
static void _se_uicc_init(void)
{
_se_uicc_prepare();
- tel_register_noti_event(gdbus_uicc_handle,
- TAPI_NOTI_SIM_STATUS,
- _se_uicc_status_noti_cb,
- NULL);
+ tel_register_noti_event(gdbus_uicc_handle, TAPI_NOTI_SIM_STATUS,
+ _se_uicc_status_noti_cb, NULL);
}
static void _se_uicc_deinit()
{
- if (gdbus_uicc_handle != NULL) {
- tel_deregister_noti_event(gdbus_uicc_handle,
- TAPI_NOTI_SIM_STATUS);
+ if (gdbus_uicc_handle != NULL)
+ {
+ tel_deregister_noti_event(gdbus_uicc_handle, TAPI_NOTI_SIM_STATUS);
tel_deinit(gdbus_uicc_handle);
{
net_nfc_target_handle_s *result = NULL;
- if (gdbus_uicc_ready == SE_UICC_READY && gdbus_uicc_handle != NULL) {
+ if (gdbus_uicc_ready == SE_UICC_READY && gdbus_uicc_handle != NULL)
result = (net_nfc_target_handle_s *)gdbus_uicc_handle;
- }
return result;
}
static bool _se_is_uicc_handle(net_nfc_target_handle_s *handle)
{
- return (gdbus_uicc_ready == SE_UICC_READY &&
- gdbus_uicc_handle != NULL &&
+ return (gdbus_uicc_ready == SE_UICC_READY && gdbus_uicc_handle != NULL &&
(TapiHandle *)handle == gdbus_uicc_handle);
}
net_nfc_server_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
/*turn off ESE*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_ESE,
- SECURE_ELEMENT_OFF_MODE,
- &result);
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+ SECURE_ELEMENT_OFF_MODE, &result);
/*turn off UICC*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_UICC,
- SECURE_ELEMENT_OFF_MODE,
- &result);
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_OFF_MODE, &result);
return NET_NFC_OK;
}
{
net_nfc_error_e result = NET_NFC_OK;
- switch (type) {
+ switch (type)
+ {
case SECURE_ELEMENT_TYPE_UICC :
- if (gdbus_se_setting.busy == false) {
- if (gdbus_uicc_ready == SE_UICC_READY) {
+ if (false == gdbus_se_setting.busy)
+ {
+ if (SE_UICC_READY == gdbus_uicc_ready)
+ {
_se_uicc_enable_card_emulation();
- } else if (gdbus_uicc_ready == SE_UICC_ON_PROGRESS) {
+ }
+ else if (SE_UICC_ON_PROGRESS == gdbus_uicc_ready)
+ {
NFC_INFO("waiting for uicc initializing complete...");
net_nfc_server_se_set_se_type(SECURE_ELEMENT_TYPE_UICC);
net_nfc_server_se_set_se_mode(SECURE_ELEMENT_VIRTUAL_MODE);
gdbus_se_setting.busy = true;
- } else {
+ }
+ else
+ {
result = NET_NFC_NOT_SUPPORTED;
}
- } else {
+ }
+ else
+ {
NFC_DBG("Previous request is processing.");
result = NET_NFC_BUSY;
case SECURE_ELEMENT_TYPE_ESE :
/*turn off UICC*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_UICC,
- SECURE_ELEMENT_OFF_MODE,
- &result);
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_OFF_MODE, &result);
/*turn on ESE*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_ESE,
- SECURE_ELEMENT_VIRTUAL_MODE,
- &result);
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
+ SECURE_ELEMENT_VIRTUAL_MODE, &result);
- if (result == NET_NFC_OK) {
+ if (NET_NFC_OK == result)
+ {
NFC_INFO("card emulation changed to SECURE_ELEMENT_TYPE_ESE");
net_nfc_server_se_set_se_type(SECURE_ELEMENT_TYPE_ESE);
net_nfc_server_se_set_se_mode(SECURE_ELEMENT_VIRTUAL_MODE);
- if (vconf_set_int(VCONFKEY_NFC_SE_TYPE,
- VCONFKEY_NFC_SE_TYPE_ESE) != 0) {
+ if (vconf_set_int(VCONFKEY_NFC_SE_TYPE, VCONFKEY_NFC_SE_TYPE_ESE) != 0)
NFC_ERR("vconf_set_int failed");
- }
- } else {
+ }
+ else
+ {
NFC_ERR("net_nfc_controller_set_secure_element_mode failed, [%d]", result);
}
break;
default:
result = net_nfc_server_se_disable_card_emulation();
- if (result == NET_NFC_OK){
+ if (NET_NFC_OK == result)
+ {
NFC_INFO("card emulation turned off");
- if (vconf_set_int(VCONFKEY_NFC_SE_TYPE,
- VCONFKEY_NFC_SE_TYPE_NONE) != 0) {
+ if (vconf_set_int(VCONFKEY_NFC_SE_TYPE, VCONFKEY_NFC_SE_TYPE_NONE) != 0)
NFC_ERR("vconf_set_int failed");
- }
}
break;
}
static void se_close_secure_element_thread_func(gpointer user_data)
{
- SeDataHandle *detail = (SeDataHandle *)user_data;
net_nfc_error_e result;
+ SeDataHandle *detail = user_data;
g_assert(detail != NULL);
g_assert(detail->object != NULL);
{
/* decrease client reference count */
net_nfc_server_gdbus_decrease_se_count(
- g_dbus_method_invocation_get_sender(
- detail->invocation));
+ g_dbus_method_invocation_get_sender(detail->invocation));
result = net_nfc_server_se_close_ese();
}
/* shutdown process if it doesn't need */
if (net_nfc_server_manager_get_active() == false &&
- net_nfc_server_gdbus_is_server_busy() == false) {
+ net_nfc_server_gdbus_is_server_busy() == false)
+ {
net_nfc_server_controller_deinit();
}
}
guint arg_handle,
GVariant *smack_privilege)
{
- SeDataHandle *data;
+ bool ret;
gboolean result;
+ SeDataHandle *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(SeDataHandle, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
result = net_nfc_server_controller_async_queue_push(
se_close_secure_element_thread_func, data);
- if (result == FALSE)
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Se.ThreadError",
static void se_get_atr_thread_func(gpointer user_data)
{
- SeDataHandle *detail = (SeDataHandle *)user_data;
- net_nfc_error_e result = NET_NFC_OK;
- data_s *atr = NULL;
GVariant *data;
+ data_s *atr = NULL;
+ SeDataHandle *detail = user_data;
+ net_nfc_error_e result = NET_NFC_OK;
g_assert(detail != NULL);
g_assert(detail->object != NULL);
}
else if (net_nfc_server_se_is_ese_handle(detail->handle) == true)
{
- net_nfc_controller_secure_element_get_atr(detail->handle, &atr,
- &result);
+ net_nfc_controller_secure_element_get_atr(detail->handle, &atr, &result);
}
else
{
data = net_nfc_util_gdbus_data_to_variant(atr);
- net_nfc_gdbus_secure_element_complete_get_atr(
- detail->object,
- detail->invocation,
- result,
- data);
+ net_nfc_gdbus_secure_element_complete_get_atr(detail->object, detail->invocation,
+ result, data);
- if (atr != NULL) {
+ if (atr != NULL)
+ {
net_nfc_util_free_data(atr);
g_free(atr);
}
guint arg_handle,
GVariant *smack_privilege)
{
- SeDataHandle *data;
+ bool ret;
gboolean result;
+ SeDataHandle *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "r") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "r");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(SeDataHandle, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->invocation = g_object_ref(invocation);
data->handle = GUINT_TO_POINTER(arg_handle);
- result = net_nfc_server_controller_async_queue_push(
- se_get_atr_thread_func, data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(se_get_atr_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Se.ThreadError",
static void se_open_secure_element_thread_func(gpointer user_data)
{
- SeDataSeType *detail = (SeDataSeType *)user_data;
- net_nfc_target_handle_s *handle = NULL;
+ SeDataSeType *detail = user_data;
net_nfc_error_e result = NET_NFC_OK;
+ net_nfc_target_handle_s *handle = NULL;
g_assert(detail != NULL);
g_assert(detail->object != NULL);
{
#if 0 /* opening SE doesn't affect card emulation */
/*off ESE*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_ESE,
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE,
SECURE_ELEMENT_OFF_MODE, &result);
/*Off UICC. UICC SHOULD not be detected by external reader when
{
#if 0 /* opening SE doesn't affect card emulation */
/*off UICC*/
- net_nfc_controller_set_secure_element_mode(
- SECURE_ELEMENT_TYPE_UICC,
+ net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC,
SECURE_ELEMENT_OFF_MODE, &result);
#endif
handle = net_nfc_server_se_open_ese();
/* increase client reference count */
net_nfc_server_gdbus_increase_se_count(
- g_dbus_method_invocation_get_sender(
- detail->invocation));
+ g_dbus_method_invocation_get_sender(detail->invocation));
}
else
{
handle = NULL;
}
- net_nfc_gdbus_secure_element_complete_open_secure_element(
- detail->object,
- detail->invocation,
- result,
- (guint)handle);
+ net_nfc_gdbus_secure_element_complete_open_secure_element(detail->object,
+ detail->invocation, result, (guint)handle);
g_object_unref(detail->invocation);
g_object_unref(detail->object);
gint arg_type,
GVariant *smack_privilege)
{
- SeDataSeType *data;
+ bool ret;
gboolean result;
+ SeDataSeType *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(SeDataSeType, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
result = net_nfc_server_controller_async_queue_push(
se_open_secure_element_thread_func, data);
- if (result == FALSE)
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Se.ThreadError",
static void se_send_apdu_thread_func(gpointer user_data)
{
- SeDataApdu *detail = (SeDataApdu *)user_data;
- data_s apdu_data = { NULL, 0 };
data_s *response = NULL;
- net_nfc_error_e result = NET_NFC_OK;
GVariant *rspdata = NULL;
+ SeDataApdu *detail = user_data;
+ data_s apdu_data = { NULL, 0 };
+ net_nfc_error_e result = NET_NFC_OK;
g_assert(detail != NULL);
g_assert(detail->object != NULL);
rspdata = net_nfc_util_gdbus_data_to_variant(response);
- net_nfc_gdbus_secure_element_complete_send_apdu(
- detail->object,
- detail->invocation,
- result,
- rspdata);
+ net_nfc_gdbus_secure_element_complete_send_apdu(detail->object, detail->invocation,
+ result, rspdata);
if (response != NULL)
{
GVariant *apdudata,
GVariant *smack_privilege)
{
- SeDataApdu *data;
+ bool ret;
gboolean result;
+ SeDataApdu *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(SeDataApdu, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->handle = GUINT_TO_POINTER(arg_handle);
data->data = g_variant_ref(apdudata);
- result = net_nfc_server_controller_async_queue_push(
- se_send_apdu_thread_func, data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(se_send_apdu_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Se.ThreadError",
static void _se_set_card_emulation_thread_func(gpointer user_data)
{
- SeSetCardEmul *data = (SeSetCardEmul *)user_data;
+ SeSetCardEmul *data = user_data;
net_nfc_error_e result = NET_NFC_OK;
g_assert(data != NULL);
if (data->mode == NET_NFC_CARD_EMELATION_ENABLE)
{
- net_nfc_controller_set_secure_element_mode(
- net_nfc_server_se_get_se_mode(),
- SECURE_ELEMENT_VIRTUAL_MODE,
- &result);
- if (result == NET_NFC_OK)
+ net_nfc_controller_set_secure_element_mode(net_nfc_server_se_get_se_mode(),
+ SECURE_ELEMENT_VIRTUAL_MODE, &result);
+
+ if (NET_NFC_OK == result)
{
NFC_DBG("changed to CARD EMULATION ON");
- net_nfc_server_se_set_se_mode(
- SECURE_ELEMENT_VIRTUAL_MODE);
+ net_nfc_server_se_set_se_mode(SECURE_ELEMENT_VIRTUAL_MODE);
}
else
{
}
else if (data->mode == NET_NFC_CARD_EMULATION_DISABLE)
{
- net_nfc_controller_set_secure_element_mode(
- net_nfc_server_se_get_se_mode(),
- SECURE_ELEMENT_OFF_MODE,
- &result);
- if (result == NET_NFC_OK)
+ net_nfc_controller_set_secure_element_mode(net_nfc_server_se_get_se_mode(),
+ SECURE_ELEMENT_OFF_MODE, &result);
+ if (NET_NFC_OK == result)
{
NFC_DBG("changed to CARD EMULATION OFF");
gint arg_mode,
GVariant *smack_privilege)
{
- SeSetCardEmul *data;
+ bool ret;
gboolean result;
+ SeSetCardEmul *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(SeSetCardEmul, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
result = net_nfc_server_controller_async_queue_push(
_se_set_card_emulation_thread_func, data);
- if (result == FALSE)
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Se.ThreadError",
static void se_set_data_thread_func(gpointer user_data)
{
- SeDataSeType *data = (SeDataSeType *)user_data;
+ SeDataSeType *data = user_data;
gboolean isTypeChanged = FALSE;
net_nfc_error_e result = NET_NFC_OK;
isTypeChanged = TRUE;
}
- net_nfc_gdbus_secure_element_complete_set(data->object,
- data->invocation, result);
+ net_nfc_gdbus_secure_element_complete_set(data->object, data->invocation, result);
if (isTypeChanged)
- net_nfc_gdbus_secure_element_emit_se_type_changed(data->object,
- data->se_type);
+ net_nfc_gdbus_secure_element_emit_se_type_changed(data->object, data->se_type);
g_object_unref(data->invocation);
g_object_unref(data->object);
g_free(data);
}
-static gboolean se_handle_set(
- NetNfcGDbusSecureElement *object,
- GDBusMethodInvocation *invocation,
- gint arg_type,
- GVariant *smack_privilege)
+static gboolean se_handle_set(NetNfcGDbusSecureElement *object,
+ GDBusMethodInvocation *invocation, gint arg_type, GVariant *smack_privilege)
{
- SeDataSeType *data;
+ bool ret;
gboolean result;
+ SeDataSeType *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(SeDataSeType, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->invocation = g_object_ref(invocation);
data->se_type = arg_type;
- result = net_nfc_server_controller_async_queue_push(
- se_set_data_thread_func, data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(se_set_data_thread_func, data);
+
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Se.ThreadError",
static void se_get_data_thread_func(gpointer user_data)
{
- SeDataSeType *data = (SeDataSeType *)user_data;
+ SeDataSeType *data = user_data;
net_nfc_error_e result = NET_NFC_OK;
g_assert(data != NULL);
g_assert(data->object != NULL);
g_assert(data->invocation != NULL);
- net_nfc_gdbus_secure_element_complete_get(data->object,
- data->invocation,
- net_nfc_server_se_get_se_type(),
- result);
+ net_nfc_gdbus_secure_element_complete_get(data->object, data->invocation,
+ net_nfc_server_se_get_se_type(), result);
g_object_unref(data->invocation);
g_object_unref(data->object);
g_free(data);
}
-static gboolean se_handle_get(
- NetNfcGDbusSecureElement *object,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege)
+static gboolean se_handle_get(NetNfcGDbusSecureElement *object,
+ GDBusMethodInvocation *invocation, GVariant *smack_privilege)
{
- SeDataSeType *data;
+ bool ret;
gboolean result;
+ SeDataSeType *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "r") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "r");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(SeDataSeType, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->object = g_object_ref(object);
data->invocation = g_object_ref(invocation);
- result = net_nfc_server_controller_async_queue_push(
- se_get_data_thread_func, data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(se_get_data_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Se.ThreadError",
static void _se_change_card_emulation_mode_thread_func(gpointer user_data)
{
- ChangeCardEmulMode *data = (ChangeCardEmulMode *)user_data;
+ bool isChanged = false;
net_nfc_error_e result = NET_NFC_OK;
uint8_t current_mode, return_mode;
- bool isChanged = false;
+ ChangeCardEmulMode *data = (ChangeCardEmulMode *)user_data;
g_assert(data != NULL);
g_assert(data->object != NULL);
current_mode = net_nfc_server_se_get_se_mode();
- if(data->mode == SECURE_ELEMENT_ACTIVE_STATE && current_mode == SECURE_ELEMENT_TYPE_INVALID)
+ if(data->mode == SECURE_ELEMENT_ACTIVE_STATE
+ && current_mode == SECURE_ELEMENT_TYPE_INVALID)
{
return_mode = net_nfc_server_se_get_return_se_mode();
result = net_nfc_server_se_change_se(return_mode);
isChanged = true;
}
- else if(data->mode == SECURE_ELEMENT_INACTIVE_STATE && current_mode != SECURE_ELEMENT_TYPE_INVALID)
+ else if(data->mode == SECURE_ELEMENT_INACTIVE_STATE
+ && current_mode != SECURE_ELEMENT_TYPE_INVALID)
{
result = net_nfc_server_se_disable_card_emulation();
isChanged = true;
if(isChanged)
{
- net_nfc_gdbus_secure_element_emit_card_emulation_mode_changed(data->object, data->mode);
+ net_nfc_gdbus_secure_element_emit_card_emulation_mode_changed(data->object,
+ data->mode);
}
g_object_unref(data->invocation);
gint arg_mode,
GVariant *smack_privilege)
{
- SeSetCardEmul *data;
+ bool ret;
gboolean result;
+ SeSetCardEmul *data;
- NFC_DBG(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_DBG(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_try_new0(ChangeCardEmulMode, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
result = net_nfc_server_controller_async_queue_push(
_se_change_card_emulation_mode_thread_func, data);
- if (result == FALSE)
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Se.ThreadError",
gboolean net_nfc_server_se_init(GDBusConnection *connection)
{
- GError *error = NULL;
gboolean result;
+ GError *error = NULL;
if (se_skeleton)
g_object_unref(se_skeleton);
se_skeleton = net_nfc_gdbus_secure_element_skeleton_new();
- g_signal_connect(se_skeleton,
- "handle-set",
- G_CALLBACK(se_handle_set),
- NULL);
-
- g_signal_connect(se_skeleton,
- "handle-get",
- G_CALLBACK(se_handle_get),
- NULL);
-
- g_signal_connect(se_skeleton,
- "handle-set-card-emulation",
- G_CALLBACK(_se_handle_set_card_emulation),
- NULL);
-
- g_signal_connect(se_skeleton,
- "handle-open-secure-element",
- G_CALLBACK(se_handle_open_secure_element),
- NULL);
-
- g_signal_connect(se_skeleton,
- "handle-close-secure-element",
- G_CALLBACK(se_handle_close_secure_element),
- NULL);
-
- g_signal_connect(se_skeleton,
- "handle-get-atr",
- G_CALLBACK(se_handle_get_atr),
- NULL);
-
- g_signal_connect(se_skeleton,
- "handle-send-apdu",
- G_CALLBACK(se_handle_send_apdu),
- NULL);
-
- g_signal_connect(se_skeleton,
- "handle-change-card-emulation-mode",
- G_CALLBACK(se_handle_change_card_emulation_mode),
- NULL);
-
- result = g_dbus_interface_skeleton_export(
- G_DBUS_INTERFACE_SKELETON(se_skeleton),
- connection,
- "/org/tizen/NetNfcService/SecureElement",
- &error);
- if (result == FALSE)
+ g_signal_connect(se_skeleton, "handle-set", G_CALLBACK(se_handle_set), NULL);
+
+ g_signal_connect(se_skeleton, "handle-get", G_CALLBACK(se_handle_get), NULL);
+
+ g_signal_connect(se_skeleton, "handle-set-card-emulation",
+ G_CALLBACK(_se_handle_set_card_emulation), NULL);
+
+ g_signal_connect(se_skeleton, "handle-open-secure-element",
+ G_CALLBACK(se_handle_open_secure_element), NULL);
+
+ g_signal_connect(se_skeleton, "handle-close-secure-element",
+ G_CALLBACK(se_handle_close_secure_element), NULL);
+
+ g_signal_connect(se_skeleton, "handle-get-atr", G_CALLBACK(se_handle_get_atr), NULL);
+
+ g_signal_connect(se_skeleton, "handle-send-apdu",
+ G_CALLBACK(se_handle_send_apdu), NULL);
+
+ g_signal_connect(se_skeleton, "handle-change-card-emulation-mode",
+ G_CALLBACK(se_handle_change_card_emulation_mode), NULL);
+
+ result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(se_skeleton),
+ connection, "/org/tizen/NetNfcService/SecureElement", &error);
+ if (FALSE == result)
{
NFC_ERR("can not skeleton_export %s", error->message);
static void se_detected_thread_func(gpointer user_data)
{
- net_nfc_target_handle_s *handle = NULL;
uint32_t devType = 0;
GVariant *data = NULL;
net_nfc_error_e result = NET_NFC_OK;
+ net_nfc_target_handle_s *handle = NULL;
g_assert(user_data != NULL);
- if (se_skeleton == NULL)
+ if (NULL == se_skeleton)
{
NFC_ERR("se skeleton is not initialized");
return;
}
- g_variant_get((GVariant *)user_data,
- "uu@a(y)",
- (guint *)&handle,
- &devType,
- &data);
+ g_variant_get((GVariant *)user_data, "uu@a(y)", (guint *)&handle, &devType, &data);
net_nfc_server_se_set_current_ese_handle(handle);
NFC_DBG("trying to connect to ESE = [0x%p]", handle);
if (!net_nfc_controller_connect(handle, &result))
- {
NFC_DBG("connect failed = [%d]", result);
- }
- net_nfc_gdbus_secure_element_emit_ese_detected(
- se_skeleton,
- GPOINTER_TO_UINT(handle),
- devType,
- data);
+ net_nfc_gdbus_secure_element_emit_ese_detected(se_skeleton, GPOINTER_TO_UINT(handle),
+ devType, data);
g_variant_unref((GVariant *)user_data);
}
static void se_transcation_thread_func(gpointer user_data)
{
- ServerSeData *detail = (ServerSeData *)user_data;
bool fg_dispatch;
pid_t focus_app_pid;
+ ServerSeData *detail = user_data;
+
g_assert(user_data != NULL);
void net_nfc_server_se_detected(void *info)
{
+ gboolean ret;
+ GVariant *data;
+ GVariant *parameter;
net_nfc_request_target_detected_t *se_target =
(net_nfc_request_target_detected_t *)info;
- GVariant *parameter;
- GVariant *data;
- data = net_nfc_util_gdbus_buffer_to_variant(
- se_target->target_info_values.buffer,
+ data = net_nfc_util_gdbus_buffer_to_variant(se_target->target_info_values.buffer,
se_target->target_info_values.length);
- parameter = g_variant_new("uu@a(y)",
- GPOINTER_TO_UINT(se_target->handle),
- se_target->devType,
- data);
- if (parameter != NULL) {
- if (net_nfc_server_controller_async_queue_push(
- se_detected_thread_func,
- parameter) == FALSE) {
+ parameter = g_variant_new("uu@a(y)", GPOINTER_TO_UINT(se_target->handle),
+ se_target->devType, data);
+ if (parameter != NULL)
+ {
+ ret = net_nfc_server_controller_async_queue_push(se_detected_thread_func,
+ parameter);
+ if (FALSE == ret)
+ {
NFC_ERR("can not push to controller thread");
g_variant_unref(parameter);
}
- } else {
+ }
+ else
+ {
NFC_ERR("g_variant_new failed");
}
void net_nfc_server_se_transaction_received(void *info)
{
- net_nfc_request_se_event_t *se_event =
- (net_nfc_request_se_event_t *)info;
+ gboolean ret;
ServerSeData *detail;
+ net_nfc_request_se_event_t *se_event = (net_nfc_request_se_event_t *)info;
detail = g_try_new0(ServerSeData, 1);
- if (detail != NULL) {
+ if (detail != NULL)
+ {
detail->event = se_event->request_type;
- if (se_event->aid.buffer != NULL && se_event->aid.length > 0) {
- if (net_nfc_util_alloc_data(&detail->aid,
- se_event->aid.length) == true) {
- memcpy(detail->aid.buffer, se_event->aid.buffer,
- se_event->aid.length);
- }
+ if (se_event->aid.buffer != NULL && se_event->aid.length > 0)
+ {
+ if (net_nfc_util_alloc_data(&detail->aid, se_event->aid.length) == true)
+ memcpy(detail->aid.buffer, se_event->aid.buffer, se_event->aid.length);
}
- if (se_event->param.buffer != NULL &&
- se_event->param.length > 0) {
- if (net_nfc_util_alloc_data(&detail->param,
- se_event->param.length) == true) {
- memcpy(detail->param.buffer,
- se_event->param.buffer,
- se_event->param.length);
- }
+ if (se_event->param.buffer != NULL && se_event->param.length > 0)
+ {
+ if (net_nfc_util_alloc_data(&detail->param, se_event->param.length) == true)
+ memcpy(detail->param.buffer, se_event->param.buffer, se_event->param.length);
}
- if (net_nfc_server_controller_async_queue_push(
- se_transcation_thread_func, detail) == FALSE) {
+ ret = net_nfc_server_controller_async_queue_push(
+ se_transcation_thread_func, detail);
+ if (FALSE == ret)
+ {
NFC_ERR("can not push to controller thread");
net_nfc_util_free_data(&detail->param);
g_free(detail);
}
- } else {
+ }
+ else
+ {
NFC_ERR("g_new0 failed");
}
#include "net_nfc_util_gdbus_internal.h"
#include "net_nfc_server_context.h"
-/* declaration */
-static gboolean _handle_start_server(
- NetNfcGDbusSnep *object,
- GDBusMethodInvocation *invocation,
- guint arg_handle,
- guint arg_sap,
- const gchar *arg_san,
- guint arg_user_data,
- GVariant *arg_privilege);
-
-static gboolean _handle_start_client(
- NetNfcGDbusSnep *object,
- GDBusMethodInvocation *invocation,
- guint arg_handle,
- guint arg_sap,
- const gchar *arg_san,
- guint arg_user_data,
- GVariant *arg_privilege);
-
-static gboolean _handle_client_send_request(
- NetNfcGDbusSnep *object,
- GDBusMethodInvocation *invocation,
- guint arg_snep_handle,
- guint arg_type,
- GVariant *arg_ndef_msg,
- GVariant *arg_privilege);
-
-static gboolean _handle_stop_snep(
- NetNfcGDbusSnep *object,
- GDBusMethodInvocation *invocation,
- guint arg_handle,
- guint arg_snep_handle,
- GVariant *arg_privilege);
-
-static void snep_server_start_thread_func(gpointer user_data);
-
-static void snep_client_start_thread_func(gpointer user_data);
-
-static void snep_client_send_request_thread_func(gpointer user_data);
-
-static void snep_stop_service_thread_func(gpointer user_data);
-
/* definition */
static NetNfcGDbusSnep *snep_skeleton = NULL;
static void _emit_snep_event_signal(GVariant *parameter,
- net_nfc_snep_handle_h handle,
- net_nfc_error_e result,
- uint32_t type,
- data_s *data)
+ net_nfc_snep_handle_h handle, net_nfc_error_e result, uint32_t type, data_s *data)
{
- GDBusConnection *connection;
+ gboolean ret;
char *client_id;
void *user_data;
GVariant *arg_data;
GError *error = NULL;
+ GDBusConnection *connection;
- g_variant_get(parameter, "(usu)",
- (guint *)&connection,
- &client_id,
+ g_variant_get(parameter, "(usu)", (guint *)&connection, &client_id,
(guint *)&user_data);
arg_data = net_nfc_util_gdbus_data_to_variant(data);
- if (g_dbus_connection_emit_signal(
+ ret = g_dbus_connection_emit_signal(
connection,
client_id,
"/org/tizen/NetNfcService/Snep",
"SnepEvent",
g_variant_new("(uui@a(y)u)", GPOINTER_TO_UINT(handle), type, (gint)result,
arg_data, GPOINTER_TO_UINT(user_data)),
- &error) == false)
+ &error);
+ if (false == ret)
{
- if (error != NULL && error->message != NULL) {
+ if (error != NULL && error->message != NULL)
NFC_ERR("g_dbus_connection_emit_signal failed : %s", error->message);
- } else {
+ else
NFC_ERR("g_dbus_connection_emit_signal failed");
- }
}
g_free(client_id);
}
static net_nfc_error_e _snep_server_cb(net_nfc_snep_handle_h handle,
- net_nfc_error_e result,
- uint32_t type,
- data_s *data,
- void *user_param)
+ net_nfc_error_e result, uint32_t type, data_s *data, void *user_param)
{
- GVariant *parameter = (GVariant *)user_param;
-
data_s *temp = data;
+ GVariant *parameter = (GVariant *)user_param;
NFC_DBG("type [%d], result [%d], data [%p], user_param [%p]",
type, result, data, user_param);
{
uint32_t max_len = 0;
- net_nfc_server_snep_parse_get_request(data, &max_len,
- temp);
+ net_nfc_server_snep_parse_get_request(data, &max_len, temp);
}
break;
break;
}
- if (result < NET_NFC_OK) {
+ if (result < NET_NFC_OK)
type = NET_NFC_LLCP_STOP;
- }
- _emit_snep_event_signal(parameter, handle,
- result, type, data);
+ _emit_snep_event_signal(parameter, handle, result, type, data);
- if (type == NET_NFC_LLCP_STOP) {
+ if (NET_NFC_LLCP_STOP == type)
g_object_unref(parameter);
- }
return result;
}
static void snep_server_start_thread_func(gpointer user_data)
{
- NetNfcGDbusSnep *object;
- GDBusMethodInvocation *invocation;
- net_nfc_target_handle_s *arg_handle;
guint arg_sap;
gchar *arg_san;
+ GVariant *parameter;
void *arg_user_data;
net_nfc_error_e result;
-
- GVariant *parameter;
+ NetNfcGDbusSnep *object;
GDBusConnection *connection;
+ GDBusMethodInvocation *invocation;
+ net_nfc_target_handle_s *arg_handle;
- if (user_data == NULL)
- {
- NFC_ERR("cannot get SNEP client data");
-
- return;
- }
+ RET_IF(NULL == user_data);
g_variant_get((GVariant *)user_data,
"(uuuusu)",
GPOINTER_TO_UINT(g_object_ref(connection)),
g_dbus_method_invocation_get_sender(invocation),
GPOINTER_TO_UINT(arg_user_data));
- if (parameter != NULL) {
- result = net_nfc_server_snep_server(arg_handle,
- arg_san,
- arg_sap,
- _snep_server_cb,
- parameter);
- if (result != NET_NFC_OK) {
- NFC_ERR("net_nfc_server_snep_server failed, [%d]",
- result);
+
+ if (parameter != NULL)
+ {
+ result = net_nfc_server_snep_server(arg_handle, arg_san, arg_sap,
+ _snep_server_cb, parameter);
+ if (result != NET_NFC_OK)
+ {
+ NFC_ERR("net_nfc_server_snep_server failed, [%d]", result);
g_object_unref(connection);
g_variant_unref(parameter);
}
- } else {
+ }
+ else
+ {
NFC_ERR("g_variant_new failed");
g_object_unref(connection);
guint arg_user_data,
GVariant *arg_privilege)
{
- GVariant *parameter;
+ bool ret;
gboolean result;
+ GVariant *parameter;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- arg_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
if (parameter != NULL)
{
- if ((result = net_nfc_server_controller_async_queue_push(
- snep_server_start_thread_func, parameter)) == FALSE)
+ result = net_nfc_server_controller_async_queue_push(
+ snep_server_start_thread_func, parameter);
+ if (FALSE == result)
{
NFC_ERR("net_nfc_server_controller_async_queue_push failed");
NFC_ERR("g_variant_new failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Snep.MemoryError",
- "Out of memory");
+ "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
result = FALSE;
}
_emit_snep_event_signal(parameter, handle, result, type, data);
- if (type == NET_NFC_LLCP_STOP) {
+ if (NET_NFC_LLCP_STOP == type)
g_variant_unref(parameter);
- }
return result;
}
static void snep_client_start_thread_func(gpointer user_data)
{
- NetNfcGDbusSnep *object;
- GDBusMethodInvocation *invocation;
- net_nfc_target_handle_s *arg_handle;
guint arg_sap;
gchar *arg_san;
+ GVariant *parameter;
void *arg_user_data;
net_nfc_error_e result;
-
- GVariant *parameter;
+ NetNfcGDbusSnep *object;
GDBusConnection *connection;
+ GDBusMethodInvocation *invocation;
+ net_nfc_target_handle_s *arg_handle;
- if (user_data == NULL)
- {
- NFC_ERR("cannot get SNEP client data");
-
- return;
- }
+ RET_IF(NULL == user_data);
g_variant_get((GVariant *)user_data,
"(uuuusu)",
GPOINTER_TO_UINT(g_object_ref(connection)),
g_dbus_method_invocation_get_sender(invocation),
GPOINTER_TO_UINT(arg_user_data));
- if (parameter != NULL) {
- result = net_nfc_server_snep_client(arg_handle,
- arg_san,
- arg_sap,
- _snep_start_client_cb,
- parameter);
- if (result != NET_NFC_OK) {
- NFC_ERR("net_nfc_server_snep_client failed, [%d]",
- result);
+
+ if (parameter != NULL)
+ {
+ result = net_nfc_server_snep_client(arg_handle, arg_san, arg_sap,
+ _snep_start_client_cb, parameter);
+ if (result != NET_NFC_OK)
+ {
+ NFC_ERR("net_nfc_server_snep_client failed, [%d]", result);
g_object_unref(connection);
g_variant_unref(parameter);
}
- } else {
+ }
+ else
+ {
NFC_ERR("g_variant_new failed");
g_object_unref(connection);
guint arg_user_data,
GVariant *arg_privilege)
{
- GVariant *parameter;
+ bool ret;
gboolean result;
+ GVariant *parameter;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- arg_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
if (parameter != NULL)
{
- if ((result = net_nfc_server_controller_async_queue_push(
- snep_client_start_thread_func, parameter)) == FALSE)
+ result = net_nfc_server_controller_async_queue_push(
+ snep_client_start_thread_func, parameter);
+ if (FALSE == result)
{
NFC_ERR("net_nfc_server_controller_async_queue_push failed");
NFC_ERR("g_variant_new failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Snep.MemoryError",
- "Out of memory");
+ "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
result = FALSE;
}
NFC_DBG("type [%d], result [%d], data [%p], user_param [%p]",
type, result, data, user_param);
- if (parameter != NULL) {
+ if (parameter != NULL)
+ {
+ GVariant *arg_ndef_msg;
NetNfcGDbusSnep *object;
+ GVariant *arg_data = NULL;
+ net_nfc_snep_type_t arg_type;
GDBusMethodInvocation *invocation;
net_nfc_snep_handle_h arg_snep_handle;
- net_nfc_snep_type_t arg_type;
- GVariant *arg_ndef_msg;
- GVariant *arg_data = NULL;
g_variant_get(parameter,
"(uuuu@a(y))",
(guint *)&arg_type,
&arg_ndef_msg);
- if (data != NULL && data->buffer != NULL && data->length > 0) {
+ if (data != NULL && data->buffer != NULL && data->length > 0)
arg_data = net_nfc_util_gdbus_data_to_variant(data);
- } else {
+ else
arg_data = net_nfc_util_gdbus_buffer_to_variant(NULL, 0);
- }
- net_nfc_gdbus_snep_complete_client_request(object,
- invocation,
- result,
- type,
- arg_data);
+ net_nfc_gdbus_snep_complete_client_request(object, invocation, result,
+ type, arg_data);
g_variant_unref(arg_ndef_msg);
g_variant_unref(parameter);
result = NET_NFC_OK;
- } else {
+ }
+ else
+ {
result = NET_NFC_NULL_PARAMETER;
}
static void snep_client_send_request_thread_func(gpointer user_data)
{
+ net_nfc_error_e result;
+ GVariant *arg_ndef_msg;
NetNfcGDbusSnep *object;
+ data_s data = { NULL, };
+ net_nfc_snep_type_t arg_type;
GDBusMethodInvocation *invocation;
net_nfc_server_snep_context_t *arg_snep_handle;
- net_nfc_snep_type_t arg_type;
- GVariant *arg_ndef_msg;
- data_s data = { NULL, };
- net_nfc_error_e result;
- if (user_data == NULL)
- {
- NFC_ERR("cannot get SNEP client data");
-
- return;
- }
+ RET_IF(NULL == user_data);
g_variant_get((GVariant *)user_data,
"(uuuu@a(y))",
net_nfc_util_gdbus_variant_to_data_s(arg_ndef_msg, &data);
- result = net_nfc_server_snep_client_request(arg_snep_handle,
- arg_type,
- &data,
- _snep_client_request_cb,
- user_data);
+ result = net_nfc_server_snep_client_request(arg_snep_handle, arg_type,
+ &data, _snep_client_request_cb, user_data);
if (result != NET_NFC_OK)
{
GVariant *resp;
- NFC_ERR("net_nfc_server_snep_client_request "
- "failed, [%d]",result);
+ NFC_ERR("net_nfc_server_snep_client_request failed, [%d]",result);
resp = net_nfc_util_gdbus_buffer_to_variant(NULL, 0);
GVariant *arg_ndef_msg,
GVariant *arg_privilege)
{
- GVariant *parameter;
+ bool ret;
gboolean result;
+ GVariant *parameter;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- arg_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
if (parameter != NULL)
{
- if ((result = net_nfc_server_controller_async_queue_push(
- snep_client_send_request_thread_func, parameter)) == FALSE)
+ result = net_nfc_server_controller_async_queue_push(
+ snep_client_send_request_thread_func, parameter);
+ if (FALSE == result)
{
NFC_ERR("net_nfc_server_controller_async_queue_push failed");
NFC_ERR("g_variant_new failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Snep.MemoryError",
- "Out of memory");
+ "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
result = FALSE;
}
static void snep_stop_service_thread_func(gpointer user_data)
{
NetNfcGDbusSnep *object;
- GDBusMethodInvocation *invocation;
net_nfc_target_handle_s *handle;
+ GDBusMethodInvocation *invocation;
net_nfc_snep_handle_h snep_handle;
- if (user_data == NULL)
- {
- NFC_ERR("cannot get SNEP client data");
+ RET_IF(NULL == user_data);
- return;
- }
-
- g_variant_get((GVariant *)user_data,
- "(uuuu)",
- (guint *)&object,
- (guint *)&invocation,
- (guint *)&handle,
- (guint *)&snep_handle);
+ g_variant_get((GVariant *)user_data, "(uuuu)", (guint *)&object, (guint *)&invocation,
+ (guint *)&handle, (guint *)&snep_handle);
g_assert(object != NULL);
g_assert(invocation != NULL);
/* TODO :
- g_dbus_method_invocation_return_dbus_error(
- invocation,
- "org.tizen.NetNfcService.Snep.DataError",
- "Cannot stop SNEP service");
- */
+ g_dbus_method_invocation_return_dbus_error(invocation,
+ "org.tizen.NetNfcService.Snep.DataError", "Cannot stop SNEP service");
+ */
- net_nfc_gdbus_snep_complete_stop_snep(object,
- invocation,
- NET_NFC_OK);
+ net_nfc_gdbus_snep_complete_stop_snep(object, invocation, NET_NFC_OK);
g_object_unref(invocation);
g_object_unref(object);
guint arg_snep_handle,
GVariant *arg_privilege)
{
- GVariant *parameter;
+ bool ret;
gboolean result;
+ GVariant *parameter;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- arg_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
- parameter = g_variant_new("(uuuu)",
- GPOINTER_TO_UINT(g_object_ref(object)),
- GPOINTER_TO_UINT(g_object_ref(invocation)),
- arg_handle,
- arg_snep_handle);
+ parameter = g_variant_new("(uuuu)", GPOINTER_TO_UINT(g_object_ref(object)),
+ GPOINTER_TO_UINT(g_object_ref(invocation)), arg_handle, arg_snep_handle);
if (parameter != NULL)
{
- if ((result = net_nfc_server_controller_async_queue_push(
- snep_stop_service_thread_func, parameter)) == FALSE)
+ result = net_nfc_server_controller_async_queue_push(
+ snep_stop_service_thread_func, parameter);
+ if (FALSE == result)
{
NFC_ERR("net_nfc_server_controller_async_queue_push failed");
NFC_ERR("g_variant_new failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Snep.MemoryError",
- "Out of memory");
+ "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
result = FALSE;
}
static void _snep_activate_cb(int event, net_nfc_target_handle_s *handle,
uint32_t sap, const char *san, void *user_param)
{
- GVariant *parameter = (GVariant *)user_param;
net_nfc_error_e result = NET_NFC_OK;
+ GVariant *parameter = (GVariant *)user_param;
- NFC_DBG("event [%d], handle [%p], sap [%d], san [%s]",
- event, handle, sap, san);
+ NFC_DBG("event [%d], handle [%p], sap [%d], san [%s]", event, handle, sap, san);
- if (event == NET_NFC_LLCP_START) {
- GDBusConnection *connection;
- GVariant *param = NULL;
+ if (NET_NFC_LLCP_START == event)
+ {
char *client_id;
void *user_data;
+ GVariant *param = NULL;
+ GDBusConnection *connection;
/* start server */
- g_variant_get(parameter, "(usu)",
- (guint *)&connection,
- &client_id,
+ g_variant_get(parameter, "(usu)", (guint *)&connection, &client_id,
(guint *)&user_data);
- param = g_variant_new("(usu)",
- GPOINTER_TO_UINT(g_object_ref(connection)),
- client_id,
- GPOINTER_TO_UINT(user_data));
+ param = g_variant_new("(usu)", GPOINTER_TO_UINT(g_object_ref(connection)),
+ client_id, GPOINTER_TO_UINT(user_data));
g_free(client_id);
result = net_nfc_server_snep_server(handle, (char *)san, sap,
_snep_server_cb, param);
- if (result == NET_NFC_OK) {
- _emit_snep_event_signal(parameter, handle,
- result, event, NULL);
- } else {
- NFC_ERR("net_nfc_server_snep_server failed, [%d]",
- result);
+ if (NET_NFC_OK == result)
+ {
+ _emit_snep_event_signal(parameter, handle, result, event, NULL);
+ }
+ else
+ {
+ NFC_ERR("net_nfc_server_snep_server failed, [%d]", result);
g_variant_unref(param);
}
- } else {
- _emit_snep_event_signal(parameter, handle,
- result, NET_NFC_LLCP_UNREGISTERED, NULL);
+ }
+ else
+ {
+ _emit_snep_event_signal(parameter, handle, result, NET_NFC_LLCP_UNREGISTERED, NULL);
/* unregister server */
g_variant_unref(parameter);
static void snep_register_server_thread_func(gpointer user_data)
{
- NetNfcGDbusSnep *object;
- GDBusMethodInvocation *invocation;
guint arg_sap;
gchar *arg_san;
guint arg_user_data;
-
net_nfc_error_e result;
+ NetNfcGDbusSnep *object;
+ g_assert(user_data != NULL);
GVariant *parameter = NULL;
GDBusConnection *connection;
+ GDBusMethodInvocation *invocation;
- g_assert(user_data != NULL);
-
- g_variant_get((GVariant *)user_data,
- "(uuusu)",
- (guint *)&object,
- (guint *)&invocation,
- &arg_sap,
- &arg_san,
- &arg_user_data);
+ g_variant_get((GVariant *)user_data, "(uuusu)", (guint *)&object, (guint *)&invocation,
+ &arg_sap, &arg_san, &arg_user_data);
g_assert(object != NULL);
g_assert(invocation != NULL);
connection = g_dbus_method_invocation_get_connection(invocation);
- parameter = g_variant_new("(usu)",
- GPOINTER_TO_UINT(g_object_ref(connection)),
- g_dbus_method_invocation_get_sender(invocation),
- arg_user_data);
- if (parameter != NULL) {
+ parameter = g_variant_new("(usu)", GPOINTER_TO_UINT(g_object_ref(connection)),
+ g_dbus_method_invocation_get_sender(invocation), arg_user_data);
+ if (parameter != NULL)
+ {
/* register default snep server */
result = net_nfc_server_llcp_register_service(
g_dbus_method_invocation_get_sender(invocation),
arg_san,
_snep_activate_cb,
parameter);
- if (result != NET_NFC_OK) {
+ if (result != NET_NFC_OK)
+ {
NFC_ERR("net_nfc_service_llcp_register_service failed, [%d]", result);
g_object_unref(connection);
g_variant_unref(parameter);
}
- } else {
+ }
+ else
+ {
result = NET_NFC_ALLOC_FAIL;
g_object_unref(connection);
}
- net_nfc_gdbus_snep_complete_server_register(object,
- invocation,
- result);
+ net_nfc_gdbus_snep_complete_server_register(object, invocation, result);
g_free(arg_san);
guint arg_user_data,
GVariant *arg_privilege)
{
- GVariant *parameter;
+ bool ret;
gboolean result;
+ GVariant *parameter;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- arg_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+ "nfc-manager::p2p", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
- parameter = g_variant_new("(uuusu)",
- GPOINTER_TO_UINT(g_object_ref(object)),
- GPOINTER_TO_UINT(g_object_ref(invocation)),
- arg_sap,
- arg_san,
- arg_user_data);
+ parameter = g_variant_new("(uuusu)", GPOINTER_TO_UINT(g_object_ref(object)),
+ GPOINTER_TO_UINT(g_object_ref(invocation)), arg_sap, arg_san, arg_user_data);
if (parameter != NULL)
{
- if ((result = net_nfc_server_controller_async_queue_push(
- snep_register_server_thread_func, parameter)) == FALSE)
+ result = net_nfc_server_controller_async_queue_push(
+ snep_register_server_thread_func, parameter);
+ if (FALSE == result)
{
NFC_ERR("net_nfc_server_controller_async_queue_push failed");
NFC_ERR("g_variant_new failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Snep.MemoryError",
- "Out of memory");
+ "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
result = FALSE;
}
static void snep_unregister_server_thread_func(gpointer user_data)
{
- NetNfcGDbusSnep *object;
- GDBusMethodInvocation *invocation;
guint arg_sap;
gchar *arg_san;
-
net_nfc_error_e result;
+ NetNfcGDbusSnep *object;
+ GDBusMethodInvocation *invocation;
g_assert(user_data != NULL);
- g_variant_get((GVariant *)user_data,
- "(uuus)",
- (guint *)&object,
- (guint *)&invocation,
- &arg_sap,
- &arg_san);
+ g_variant_get((GVariant *)user_data, "(uuus)", (guint *)&object, (guint *)&invocation,
+ &arg_sap, &arg_san);
g_assert(object != NULL);
g_assert(invocation != NULL);
result = net_nfc_server_llcp_unregister_service(
- g_dbus_method_invocation_get_sender(invocation),
- arg_sap,
- arg_san);
+ g_dbus_method_invocation_get_sender(invocation), arg_sap, arg_san);
- net_nfc_gdbus_snep_complete_server_unregister(object,
- invocation,
- result);
+ net_nfc_gdbus_snep_complete_server_unregister(object, invocation, result);
g_free(arg_san);
const gchar *arg_san,
GVariant *arg_privilege)
{
- GVariant *parameter;
+ bool ret;
gboolean result;
+ GVariant *parameter;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- arg_privilege,
- "nfc-manager::p2p",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, arg_privilege,
+ "nfc-manager::p2p", "rw");
+
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
- parameter = g_variant_new("(uuus)",
- GPOINTER_TO_UINT(g_object_ref(object)),
- GPOINTER_TO_UINT(g_object_ref(invocation)),
- arg_sap,
- arg_san);
+ parameter = g_variant_new("(uuus)", GPOINTER_TO_UINT(g_object_ref(object)),
+ GPOINTER_TO_UINT(g_object_ref(invocation)), arg_sap, arg_san);
if (parameter != NULL)
{
- if ((result = net_nfc_server_controller_async_queue_push(
- snep_unregister_server_thread_func, parameter)) == FALSE)
+ result = net_nfc_server_controller_async_queue_push(
+ snep_unregister_server_thread_func, parameter);
+ if (FALSE == result)
{
NFC_ERR("net_nfc_server_controller_async_queue_push failed");
NFC_ERR("g_variant_new failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Snep.MemoryError",
- "Out of memory");
+ "org.tizen.NetNfcService.Snep.MemoryError", "Out of memory");
result = FALSE;
}
gboolean net_nfc_server_snep_init(GDBusConnection *connection)
{
- GError *error = NULL;
gboolean result;
+ GError *error = NULL;
if (snep_skeleton)
g_object_unref(snep_skeleton);
snep_skeleton = net_nfc_gdbus_snep_skeleton_new();
- g_signal_connect(snep_skeleton,
- "handle-server-register",
- G_CALLBACK(_handle_register_server),
- NULL);
-
- g_signal_connect(snep_skeleton,
- "handle-server-unregister",
- G_CALLBACK(_handle_unregister_server),
- NULL);
-
- g_signal_connect(snep_skeleton,
- "handle-server-start",
- G_CALLBACK(_handle_start_server),
- NULL);
-
- g_signal_connect(snep_skeleton,
- "handle-client-start",
- G_CALLBACK(_handle_start_client),
- NULL);
-
- g_signal_connect(snep_skeleton,
- "handle-client-request",
- G_CALLBACK(_handle_client_send_request),
- NULL);
-
- g_signal_connect(snep_skeleton,
- "handle-stop-snep",
- G_CALLBACK(_handle_stop_snep),
- NULL);
-
- result = g_dbus_interface_skeleton_export(
- G_DBUS_INTERFACE_SKELETON(snep_skeleton),
- connection,
- "/org/tizen/NetNfcService/Snep",
- &error);
- if (result == FALSE)
+ g_signal_connect(snep_skeleton, "handle-server-register",
+ G_CALLBACK(_handle_register_server), NULL);
+
+ g_signal_connect(snep_skeleton, "handle-server-unregister",
+ G_CALLBACK(_handle_unregister_server), NULL);
+
+ g_signal_connect(snep_skeleton, "handle-server-start",
+ G_CALLBACK(_handle_start_server), NULL);
+
+ g_signal_connect(snep_skeleton, "handle-client-start",
+ G_CALLBACK(_handle_start_client), NULL);
+
+ g_signal_connect(snep_skeleton, "handle-client-request",
+ G_CALLBACK(_handle_client_send_request), NULL);
+
+ g_signal_connect(snep_skeleton, "handle-stop-snep",
+ G_CALLBACK(_handle_stop_snep), NULL);
+
+ result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(snep_skeleton),
+ connection, "/org/tizen/NetNfcService/Snep", &error);
+ if (FALSE == result)
{
g_error_free(error);
static NetNfcGDbusPopup *popup_skeleton = NULL;
-static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
- GDBusMethodInvocation *invocation,
- int state,
- gint focus_state,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data);
-
static gboolean popup_handle_set(NetNfcGDbusPopup *popup_manager,
GDBusMethodInvocation *invocation,
gint state,
GVariant *smack_privilege,
gpointer user_data)
{
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ bool ret;
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "w") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "w");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
- net_nfc_server_gdbus_set_launch_state(
- g_dbus_method_invocation_get_sender(invocation),
+ net_nfc_server_gdbus_set_launch_state(g_dbus_method_invocation_get_sender(invocation),
state, focus_state);
net_nfc_gdbus_popup_complete_set(popup_manager, invocation, NET_NFC_OK);
}
static gboolean popup_handle_get(NetNfcGDbusPopup *popup_manager,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data)
+ GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
{
+ bool ret;
gboolean state;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "r") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "r");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
state = net_nfc_server_gdbus_get_launch_state(
g_dbus_method_invocation_get_sender(invocation));
- net_nfc_gdbus_popup_complete_get(popup_manager, invocation,
- NET_NFC_OK, state);
+ net_nfc_gdbus_popup_complete_get(popup_manager, invocation, NET_NFC_OK, state);
return TRUE;
}
gboolean net_nfc_server_system_handler_init(GDBusConnection *connection)
{
- GError *error = NULL;
gboolean result;
+ GError *error = NULL;
if (popup_skeleton)
g_object_unref(popup_skeleton);
popup_skeleton = net_nfc_gdbus_popup_skeleton_new();
- if (popup_skeleton == NULL)
+ if (NULL == popup_skeleton)
{
NFC_ERR("Failed to allocate popup skeleton");
return FALSE;
}
- g_signal_connect(popup_skeleton,
- "handle-set",
- G_CALLBACK(popup_handle_set),
- NULL);
-
- g_signal_connect(popup_skeleton,
- "handle-get",
- G_CALLBACK(popup_handle_get),
- NULL);
-
- result = g_dbus_interface_skeleton_export(
- G_DBUS_INTERFACE_SKELETON(popup_skeleton),
- connection,
- "/org/tizen/NetNfcService/Popup",
- &error);
- if (result == FALSE)
+ g_signal_connect(popup_skeleton, "handle-set", G_CALLBACK(popup_handle_set), NULL);
+
+ g_signal_connect(popup_skeleton, "handle-get", G_CALLBACK(popup_handle_get), NULL);
+
+ result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(popup_skeleton),
+ connection, "/org/tizen/NetNfcService/Popup", &error);
+ if (FALSE == result)
{
NFC_ERR("Can not skeleton_export %s", error->message);
net_nfc_target_handle_s *handle;
};
-
-static gboolean tag_is_isp_dep_ndef_formatable(net_nfc_target_handle_s *handle,
- int dev_type);
-
-static gboolean tag_read_ndef_message(net_nfc_target_handle_s *handle,
- int dev_type,data_s **read_ndef);
-
-static void tag_watchdog_thread_func(gpointer user_data);
-
-static void tag_get_current_tag_info_thread_func(gpointer user_data);
-
-static void tag_slave_target_detected_thread_func(gpointer user_data);
-
-
-/* methods */
-static gboolean tag_handle_is_tag_connected(NetNfcGDbusTag *tag,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean tag_handle_get_current_tag_info(NetNfcGDbusTag *tag,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean tag_handle_get_current_target_handle(NetNfcGDbusTag *tag,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data);
-
static NetNfcGDbusTag *tag_skeleton = NULL;
static net_nfc_current_target_info_s *current_target_info = NULL;
static gboolean tag_is_isp_dep_ndef_formatable(net_nfc_target_handle_s *handle,
int dev_type)
{
- uint8_t cmd[] = { 0x90, 0x60, 0x00, 0x00, 0x00 };
- net_nfc_transceive_info_s info;
+ gboolean result = false;
data_s *response = NULL;
+ net_nfc_transceive_info_s info;
net_nfc_error_e error = NET_NFC_OK;
- gboolean result = false;
+ uint8_t cmd[] = { 0x90, 0x60, 0x00, 0x00, 0x00 };
info.dev_type = dev_type;
info.trans_data.buffer = cmd;
info.trans_data.length = sizeof(cmd);
- if (net_nfc_controller_transceive(handle,
- &info,
- &response,
- &error) == false)
+ if (net_nfc_controller_transceive(handle, &info, &response, &error) == false)
{
NFC_ERR("net_nfc_controller_transceive is failed");
if (response != NULL)
{
- if (response->length == 9 &&
- response->buffer[7] == (uint8_t)0x91 &&
+ if (response->length == 9 && response->buffer[7] == (uint8_t)0x91 &&
response->buffer[8] == (uint8_t)0xAF)
{
result = TRUE;
static gboolean tag_read_ndef_message(net_nfc_target_handle_s *handle,
int dev_type, data_s **read_ndef)
{
- net_nfc_error_e result = NET_NFC_OK;
data_s *temp = NULL;
+ net_nfc_error_e result = NET_NFC_OK;
- if (handle == NULL)
- return FALSE;
-
- if (read_ndef == NULL)
- return FALSE;
+ RETV_IF(NULL == handle, FALSE);
+ RETV_IF(NULL == read_ndef, FALSE);
*read_ndef = NULL;
- if (dev_type == NET_NFC_MIFARE_DESFIRE_PICC)
+ if (NET_NFC_MIFARE_DESFIRE_PICC == dev_type)
{
if (tag_is_isp_dep_ndef_formatable(handle, dev_type) == FALSE)
{
- NFC_ERR(
- "DESFIRE : ISO-DEP ndef not formatable");
+ NFC_ERR("DESFIRE : ISO-DEP ndef not formatable");
return FALSE;
}
if (net_nfc_controller_connect(handle, &result) == false)
{
- NFC_ERR("%s failed, & retry polling!!",
- "net_nfc_controller_connect");
+ NFC_ERR("net_nfc_controller_connect failed & retry polling!!");
- if (net_nfc_controller_configure_discovery(
- NET_NFC_DISCOVERY_MODE_RESUME,
- NET_NFC_ALL_ENABLE,
- &result) == false)
+ if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_RESUME,
+ NET_NFC_ALL_ENABLE, &result) == false)
{
net_nfc_controller_exception_handler();
}
NFC_DBG("net_nfc_controller_read_ndef success");
- if (dev_type == NET_NFC_MIFARE_DESFIRE_PICC)
+ if (NET_NFC_MIFARE_DESFIRE_PICC == dev_type)
{
if (net_nfc_controller_connect(handle, &result) == false)
{
- NFC_ERR("%s failed, & retry polling!!",
- "net_nfc_controller_connect");
+ NFC_ERR("net_nfc_controller_connect failed, & retry polling!!");
- if (net_nfc_controller_configure_discovery(
- NET_NFC_DISCOVERY_MODE_RESUME,
- NET_NFC_ALL_ENABLE,
- &result) == false)
+ if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_RESUME,
+ NET_NFC_ALL_ENABLE, &result) == false)
{
net_nfc_controller_exception_handler();
}
static void tag_watchdog_thread_func(gpointer user_data)
{
- WatchDogData *watch_dog = (WatchDogData *)user_data;
+ gboolean ret;
net_nfc_target_handle_s *handle;
- net_nfc_error_e result = NET_NFC_OK;
bool is_present_target = false;
+ net_nfc_error_e result = NET_NFC_OK;
+ WatchDogData *watch_dog = user_data;
- if (watch_dog == NULL)
- {
- NFC_ERR("can not get WatchDogData");
- return;
- }
-
- if (watch_dog->handle == NULL)
- {
- NFC_ERR("can not get WatchDogData->handle");
- return;
- }
-
+ RET_IF(NULL == watch_dog);
+ RET_IF(NULL == watch_dog->handle);
/* IMPORTANT, TEMPORARY : switching context to another thread
for give CPU time */
if (handle->connection_type == NET_NFC_P2P_CONNECTION_TARGET ||
handle->connection_type == NET_NFC_TAG_CONNECTION)
{
- is_present_target = net_nfc_controller_check_target_presence(
- handle, &result);
+ is_present_target = net_nfc_controller_check_target_presence(handle, &result);
}
- if (is_present_target == true)
+ if (true == is_present_target)
{
- if(net_nfc_server_controller_async_queue_push(
- tag_watchdog_thread_func,
- watch_dog) == FALSE)
+ ret = net_nfc_server_controller_async_queue_push(tag_watchdog_thread_func,
+ watch_dog);
+ if(FALSE == ret)
{
NFC_ERR("can not create watch dog");
g_free(watch_dog);
return;
}
- if (result != NET_NFC_NOT_INITIALIZED &&
- result != NET_NFC_INVALID_HANDLE)
+ if (result != NET_NFC_NOT_INITIALIZED && result != NET_NFC_INVALID_HANDLE)
{
if(net_nfc_controller_disconnect(handle, &result) == false)
{
net_nfc_server_set_state(NET_NFC_SERVER_IDLE);
- net_nfc_gdbus_tag_emit_tag_detached(tag_skeleton,
- GPOINTER_TO_UINT(handle),
+ net_nfc_gdbus_tag_emit_tag_detached(tag_skeleton, GPOINTER_TO_UINT(handle),
watch_dog->dev_type);
g_free(watch_dog);
static void tag_get_current_tag_info_thread_func(gpointer user_data)
{
- CurrentTagInfoData *info_data =
- (CurrentTagInfoData *)user_data;
/* FIXME : net_nfc_current_target_info_s should be removed */
- net_nfc_current_target_info_s *target_info;
- net_nfc_error_e result = NET_NFC_OPERATION_FAIL;
- net_nfc_target_handle_s *handle = NULL;
- net_nfc_target_type_e dev_type = NET_NFC_UNKNOWN_TARGET;
- gboolean is_ndef_supported = FALSE;
- guint8 ndef_card_state = 0;
+ bool ret;
+ data_s *raw_data = NULL;
+ gint number_of_keys = 0;
guint32 max_data_size = 0;
+ guint8 ndef_card_state = 0;
guint32 actual_data_size = 0;
- gint number_of_keys = 0;
+ gboolean is_ndef_supported = FALSE;
+ net_nfc_target_handle_s *handle = NULL;
data_s target_info_values = { NULL, 0 };
- data_s *raw_data = NULL;
+ CurrentTagInfoData *info_data = user_data;
+ net_nfc_current_target_info_s *target_info;
+ net_nfc_error_e result = NET_NFC_OPERATION_FAIL;
+ net_nfc_target_type_e dev_type = NET_NFC_UNKNOWN_TARGET;
g_assert(info_data != NULL);
g_assert(info_data->tag != NULL);
g_assert(info_data->invocation != NULL);
target_info = net_nfc_server_get_target_info();
- if (target_info != NULL &&
- target_info->devType != NET_NFC_NFCIP1_TARGET &&
+ if (target_info != NULL && target_info->devType != NET_NFC_NFCIP1_TARGET &&
target_info->devType != NET_NFC_NFCIP1_INITIATOR)
{
handle = target_info->handle;
dev_type = target_info->devType ;
- if (net_nfc_controller_check_ndef(target_info->handle,
- &ndef_card_state,
- (int *)&max_data_size,
- (int *)&actual_data_size,
- &result) == true)
- {
+ ret = net_nfc_controller_check_ndef(target_info->handle, &ndef_card_state,
+ (int *)&max_data_size, (int *)&actual_data_size, &result);
+ if (true == ret)
is_ndef_supported = TRUE;
- }
if (is_ndef_supported)
{
- if (net_nfc_controller_read_ndef(target_info->handle,
- &raw_data, &result) == true)
- {
+ ret = net_nfc_controller_read_ndef(target_info->handle, &raw_data, &result);
+ if (true == ret)
NFC_DBG("net_nfc_controller_read_ndef is success");
- }
}
}
net_nfc_util_gdbus_data_to_variant(&target_info_values),
net_nfc_util_gdbus_data_to_variant(raw_data));
- if (raw_data != NULL) {
+ if (raw_data != NULL)
+ {
net_nfc_util_free_data(raw_data);
g_free(raw_data);
}
static void tag_slave_target_detected_thread_func(gpointer user_data)
{
- net_nfc_current_target_info_s *target;
- net_nfc_error_e result = NET_NFC_OK;
-
+ bool ret;
+ GVariant *raw_data = NULL;
guint32 max_data_size = 0;
- guint32 actual_data_size = 0;
guint8 ndef_card_state = 0;
- gboolean is_ndef_supported = FALSE;
-
- GVariant *target_info_values = NULL;
- GVariant *raw_data = NULL;
-
+ guint32 actual_data_size = 0;
WatchDogData *watch_dog = NULL;
bool isHandoverMessage = false;
+ net_nfc_error_e result = NET_NFC_OK;
+ gboolean is_ndef_supported = FALSE;
+ net_nfc_current_target_info_s *target;
+ GVariant *target_info_values = NULL;
target = net_nfc_server_get_target_info();
g_assert(target != NULL); /* raise exception!!! what;s wrong?? */
- if (tag_skeleton == NULL)
- {
- NFC_ERR("tag skeleton is not initialized");
-
- return;
- }
+ RET_IF(NULL == tag_skeleton);
if (net_nfc_controller_connect(target->handle, &result) == false)
{
NFC_ERR("connect failed & Retry Polling!!");
- if (net_nfc_controller_configure_discovery(
- NET_NFC_DISCOVERY_MODE_RESUME,
- NET_NFC_ALL_ENABLE,
- &result) == false)
- {
+ ret = net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_RESUME,
+ NET_NFC_ALL_ENABLE, &result);
+ if (false == ret)
net_nfc_controller_exception_handler();
- }
return;
}
NFC_DBG("tag is connected");
target_info_values = net_nfc_util_gdbus_buffer_to_variant(
- target->target_info_values.buffer,
- target->target_info_values.length);
+ target->target_info_values.buffer, target->target_info_values.length);
- if (net_nfc_controller_check_ndef(target->handle,
- &ndef_card_state,
- (int *)&max_data_size,
- (int *)&actual_data_size,
- &result) == true)
- {
+ ret = net_nfc_controller_check_ndef(target->handle, &ndef_card_state,
+ (int *)&max_data_size, (int *)&actual_data_size, &result);
+ if (true == ret)
is_ndef_supported = TRUE;
- }
if (is_ndef_supported)
{
NFC_DBG("support NDEF");
- if (tag_read_ndef_message(target->handle,
- target->devType,
- &recv_data) == TRUE)
+ if (tag_read_ndef_message(target->handle, target->devType, &recv_data) == TRUE)
{
- ndef_message_s *selector;
ndef_record_s *record;
+ ndef_message_s *selector;
ndef_record_s *recordasperpriority;
- result = net_nfc_server_handover_create_selector_from_rawdata(
- &selector,
+
+ result = net_nfc_server_handover_create_selector_from_rawdata(&selector,
recv_data);
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
- result =
- net_nfc_server_handover_get_carrier_record_by_priority_order(
- selector,
- &record);
+ result = net_nfc_server_handover_get_carrier_record_by_priority_order(
+ selector, &record);
isHandoverMessage = true;
- if (result == NET_NFC_OK)
+ if (NET_NFC_OK == result)
{
- net_nfc_util_create_record(
- record->TNF,
- &record->type_s, &record->id_s,
- &record->payload_s,
- &recordasperpriority);
+ net_nfc_util_create_record(record->TNF, &record->type_s, &record->id_s,
+ &record->payload_s, &recordasperpriority);
- net_nfc_server_handover_process_carrier_record(recordasperpriority, NULL, NULL);
+ net_nfc_server_handover_process_carrier_record(recordasperpriority,
+ NULL, NULL);
}
else
{
- NFC_ERR("_get_carrier_record_by_priority_order"
- " failed, [%d]",result);
+ NFC_ERR("_get_carrier_record_by_priority_order failed, [%d]",result);
}
}
else
NFC_DBG("turn on watch dog");
watch_dog = g_new0(WatchDogData, 1);
- if(watch_dog == NULL)
+ if(NULL == watch_dog)
{
NFC_ERR("Memory allocation failed");
return;
watch_dog->handle = target->handle;
if (net_nfc_server_controller_async_queue_push(
- tag_watchdog_thread_func,
- watch_dog) == FALSE)
+ tag_watchdog_thread_func, watch_dog) == FALSE)
{
NFC_ERR("can not create watch dog");
g_free(watch_dog);
static gboolean tag_handle_is_tag_connected(NetNfcGDbusTag *tag,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data)
+ GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
{
/* FIXME : net_nfc_current_target_info_s should be removed */
+ bool ret;
+ gint result;
+ gboolean is_connected = FALSE;
net_nfc_current_target_info_s *target_info;
net_nfc_target_type_e dev_type = NET_NFC_UNKNOWN_TARGET;
- gboolean is_connected = FALSE;
- gint result;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::tag",
- "r") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::tag", "r");
+
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
result = NET_NFC_SECURITY_FAIL;
result = NET_NFC_OK;
END :
- net_nfc_gdbus_tag_complete_is_tag_connected(tag,
- invocation,
- result,
- is_connected,
+ net_nfc_gdbus_tag_complete_is_tag_connected(tag, invocation, result, is_connected,
(gint32)dev_type);
return TRUE;
}
static gboolean tag_handle_get_current_tag_info(NetNfcGDbusTag *tag,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data)
+ GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
{
- CurrentTagInfoData *info_data;
+ bool ret;
gboolean result;
+ CurrentTagInfoData *info_data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::tag",
- "r") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::tag", "r");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
info_data = g_new0(CurrentTagInfoData, 1);
- if (info_data == NULL)
+ if (NULL == info_data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
info_data->invocation = g_object_ref(invocation);
result = net_nfc_server_controller_async_queue_push(
- tag_get_current_tag_info_thread_func,
- info_data);
- if (result == FALSE)
+ tag_get_current_tag_info_thread_func, info_data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.ThreadError",
}
static gboolean tag_handle_get_current_target_handle(NetNfcGDbusTag *tag,
- GDBusMethodInvocation *invocation,
- GVariant *smack_privilege,
- gpointer user_data)
+ GDBusMethodInvocation *invocation, GVariant *smack_privilege, gpointer user_data)
{
/* FIXME : net_nfc_current_target_info_s should be removed */
- net_nfc_current_target_info_s *target_info;
+ gint result;
+ gboolean ret;
net_nfc_target_handle_s *handle = NULL;
uint32_t devType = NET_NFC_UNKNOWN_TARGET;
- gint result;
+ net_nfc_current_target_info_s *target_info;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager::p2p",
- "r") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager::p2p", "r");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
result = NET_NFC_SECURITY_FAIL;
result = NET_NFC_OK;
END :
- net_nfc_gdbus_tag_complete_get_current_target_handle(tag,
- invocation,
- result,
- (handle != NULL),
- GPOINTER_TO_UINT(handle),
- devType);
+ net_nfc_gdbus_tag_complete_get_current_target_handle(tag, invocation, result,
+ (handle != NULL), GPOINTER_TO_UINT(handle), devType);
return TRUE;
}
gboolean net_nfc_server_tag_init(GDBusConnection *connection)
{
- GError *error = NULL;
gboolean result;
+ GError *error = NULL;
if (tag_skeleton)
net_nfc_server_tag_deinit();
tag_skeleton = net_nfc_gdbus_tag_skeleton_new();
- g_signal_connect(tag_skeleton,
- "handle-is-tag-connected",
- G_CALLBACK(tag_handle_is_tag_connected),
- NULL);
-
- g_signal_connect(tag_skeleton,
- "handle-get-current-tag-info",
- G_CALLBACK(tag_handle_get_current_tag_info),
- NULL);
-
- g_signal_connect(tag_skeleton,
- "handle-get-current-target-handle",
- G_CALLBACK(tag_handle_get_current_target_handle),
- NULL);
-
- result = g_dbus_interface_skeleton_export(
- G_DBUS_INTERFACE_SKELETON(tag_skeleton),
- connection,
- "/org/tizen/NetNfcService/Tag",
- &error);
- if (result == FALSE)
+ g_signal_connect(tag_skeleton, "handle-is-tag-connected",
+ G_CALLBACK(tag_handle_is_tag_connected), NULL);
+
+ g_signal_connect(tag_skeleton, "handle-get-current-tag-info",
+ G_CALLBACK(tag_handle_get_current_tag_info), NULL);
+
+ g_signal_connect(tag_skeleton, "handle-get-current-target-handle",
+ G_CALLBACK(tag_handle_get_current_target_handle), NULL);
+
+ result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(tag_skeleton),
+ connection, "/org/tizen/NetNfcService/Tag", &error);
+ if (FALSE == result)
{
NFC_ERR("can not skeleton_export %s", error->message);
target = (net_nfc_request_target_detected_t *)info;
- current_target_info = g_malloc0(
- sizeof(net_nfc_current_target_info_s) +
+ current_target_info = g_malloc0(sizeof(net_nfc_current_target_info_s) +
target->target_info_values.length);
current_target_info->handle = target->handle;
gboolean net_nfc_server_target_connected(net_nfc_target_handle_s *handle)
{
- if (current_target_info == NULL)
+ if (NULL == current_target_info)
return FALSE;
if (current_target_info->handle != handle)
void net_nfc_server_tag_target_detected(void *info)
{
- if (net_nfc_server_controller_async_queue_push(
- tag_slave_target_detected_thread_func,
- NULL) == FALSE)
- {
+ gboolean ret;
+
+ ret = net_nfc_server_controller_async_queue_push(
+ tag_slave_target_detected_thread_func, NULL);
+
+ if (FALSE == ret)
NFC_ERR("can not push to controller thread");
- }
}
static NetNfcGDbusTransceive *transceive_skeleton = NULL;
-static void transceive_thread_func(gpointer user_data);
-
-static void transceive_data_thread_func(gpointer user_data);
-
-static gboolean transceive_handle(NetNfcGDbusTransceive *transceive,
- GDBusMethodInvocation *invocation,
- guint handle,
- guint dev_type,
- GVariant *arg_data,
- GVariant *smack_privilege,
- gpointer user_data);
-
-static gboolean transceive_data_handle(NetNfcGDbusTransceive *transceive,
- GDBusMethodInvocation *invocation,
- guint handle,
- guint dev_type,
- GVariant *arg_data,
- GVariant *smack_privilege,
- gpointer user_data);
-
typedef struct _TransceiveSendData TransceiveSendData;
static void transceive_data_thread_func(gpointer user_data)
{
+ bool ret;
+ data_s *data = NULL;
+ GVariant *resp_data = NULL;
+ net_nfc_error_e result = NET_NFC_OK;
TransceiveSendData *transceive_data = user_data;
net_nfc_target_handle_s *handle =
(net_nfc_target_handle_s *)transceive_data->transceive_handle;
- net_nfc_error_e result = NET_NFC_OK;
- data_s *data = NULL;
- GVariant *resp_data = NULL;
/* use assert because it was checked in handle function */
g_assert(transceive_data != NULL);
{
NFC_DBG("call transceive");
- if (net_nfc_controller_transceive(handle,
- &transceive_data->transceive_info,
- &data,
- &result) == true)
+ ret = net_nfc_controller_transceive(handle, &transceive_data->transceive_info,
+ &data, &result);
+
+ if (true == ret)
{
if (data != NULL)
NFC_DBG("Transceive data received [%d]", data->length);
resp_data = net_nfc_util_gdbus_data_to_variant(data);
- net_nfc_gdbus_transceive_complete_transceive_data(
- transceive_data->transceive,
- transceive_data->invocation,
- (gint)result,
- resp_data);
+ net_nfc_gdbus_transceive_complete_transceive_data(transceive_data->transceive,
+ transceive_data->invocation, (gint)result, resp_data);
if (data)
{
GVariant *smack_privilege,
gpointer user_data)
{
- TransceiveSendData *data;
+ bool ret;
gboolean result;
+ TransceiveSendData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_new0(TransceiveSendData, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
data->invocation = g_object_ref(invocation);
data->transceive_handle = handle;
data->transceive_info.dev_type = dev_type;
- net_nfc_util_gdbus_variant_to_data_s(arg_data,
- &data->transceive_info.trans_data);
+ net_nfc_util_gdbus_variant_to_data_s(arg_data, &data->transceive_info.trans_data);
- result = net_nfc_server_controller_async_queue_push(
- transceive_data_thread_func, data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(transceive_data_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Transceive.ThreadError",
static void transceive_thread_func(gpointer user_data)
{
+ bool ret;
+ data_s *data = NULL;
+ net_nfc_error_e result = NET_NFC_OK;
TransceiveSendData *transceive_data = user_data;
net_nfc_target_handle_s *handle =
(net_nfc_target_handle_s *)transceive_data->transceive_handle;
- net_nfc_error_e result = NET_NFC_OK;
- data_s *data = NULL;
/* use assert because it was checked in handle function */
g_assert(transceive_data != NULL);
if (net_nfc_server_target_connected(handle) == true)
{
NFC_DBG("call transceive");
-
- if (net_nfc_controller_transceive(handle,
- &transceive_data->transceive_info,
- &data,
- &result) == true)
+ ret = net_nfc_controller_transceive(handle, &transceive_data->transceive_info,
+ &data, &result);
+ if (true == ret)
{
if (data != NULL)
{
NFC_DBG("transceive result : %d", result);
- net_nfc_gdbus_transceive_complete_transceive(
- transceive_data->transceive,
- transceive_data->invocation,
- (gint)result);
+ net_nfc_gdbus_transceive_complete_transceive(transceive_data->transceive,
+ transceive_data->invocation, (gint)result);
net_nfc_util_free_data(&transceive_data->transceive_info.trans_data);
GVariant *smack_privilege,
gpointer user_data)
{
- TransceiveSendData *data;
+ bool ret;
gboolean result;
+ TransceiveSendData *data;
- NFC_INFO(">>> REQUEST from [%s]",
- g_dbus_method_invocation_get_sender(invocation));
+ NFC_INFO(">>> REQUEST from [%s]", g_dbus_method_invocation_get_sender(invocation));
/* check privilege and update client context */
- if (net_nfc_server_gdbus_check_privilege(invocation,
- smack_privilege,
- "nfc-manager",
- "rw") == false) {
+ ret = net_nfc_server_gdbus_check_privilege(invocation, smack_privilege,
+ "nfc-manager", "rw");
+ if (false == ret)
+ {
NFC_ERR("permission denied, and finished request");
return FALSE;
}
data = g_new0(TransceiveSendData, 1);
- if (data == NULL)
+ if (NULL == data)
{
NFC_ERR("Memory allocation failed");
g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.AllocationError",
- "Can not allocate memory");
+ "org.tizen.NetNfcService.AllocationError", "Can not allocate memory");
return FALSE;
}
net_nfc_util_gdbus_variant_to_data_s(arg_data,
&data->transceive_info.trans_data);
- result = net_nfc_server_controller_async_queue_push(
- transceive_thread_func, data);
- if (result == FALSE)
+ result = net_nfc_server_controller_async_queue_push(transceive_thread_func, data);
+ if (FALSE == result)
{
g_dbus_method_invocation_return_dbus_error(invocation,
"org.tizen.NetNfcService.Transceive.ThreadError",
gboolean net_nfc_server_transceive_init(GDBusConnection *connection)
{
- GError *error = NULL;
gboolean result;
+ GError *error = NULL;
if (transceive_skeleton)
g_object_unref(transceive_skeleton);
transceive_skeleton = net_nfc_gdbus_transceive_skeleton_new();
- g_signal_connect(transceive_skeleton,
- "handle-transceive-data",
- G_CALLBACK(transceive_data_handle),
- NULL);
+ g_signal_connect(transceive_skeleton, "handle-transceive-data",
+ G_CALLBACK(transceive_data_handle), NULL);
- g_signal_connect(transceive_skeleton,
- "handle-transceive",
- G_CALLBACK(transceive_handle),
- NULL);
+ g_signal_connect(transceive_skeleton, "handle-transceive",
+ G_CALLBACK(transceive_handle), NULL);
result = g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON(transceive_skeleton),
connection,
"/org/tizen/NetNfcService/Transceive",
&error);
- if (result == FALSE)
+ if (FALSE == result)
{
g_error_free(error);
g_object_unref(transceive_skeleton);
#include "net_nfc_server_se.h"
#include "net_nfc_server_util.h"
-#define NET_NFC_MANAGER_SOUND_PATH_TASK_START "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
-#define NET_NFC_MANAGER_SOUND_PATH_TASK_END "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
-#define NET_NFC_MANAGER_SOUND_PATH_TASK_ERROR "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
+#define NET_NFC_MANAGER_SOUND_PATH_TASK_START \
+ "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
+
+#define NET_NFC_MANAGER_SOUND_PATH_TASK_END \
+ "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
+
+#define NET_NFC_MANAGER_SOUND_PATH_TASK_ERROR \
+ "/usr/share/nfc-manager-daemon/sounds/Operation_sdk.wav"
#define OSP_K_COND "__OSP_COND_NAME__"
#define OSP_K_COND_TYPE "nfc"
{
char *buffer = NULL;
size_t buffer_len = 0;
- struct passwd pwd = { 0, };
- struct passwd *pw_inhouse = NULL;
struct group grp = { 0, };
+ struct passwd pwd = { 0, };
struct group *gr_inhouse = NULL;
+ struct passwd *pw_inhouse = NULL;
- if (file == NULL)
- return false;
+ RETV_IF(NULL == file, false);
/* change permission */
fchmod(fileno(file), 0777);
/* get passwd id */
buffer_len = sysconf(_SC_GETPW_R_SIZE_MAX);
if (buffer_len == -1)
- {
buffer_len = 16384;
- }
_net_nfc_util_alloc_mem(buffer, buffer_len);
- if (buffer == NULL)
+ if (NULL == buffer)
return false;
getpwnam_r("inhouse", &pwd, buffer, buffer_len, &pw_inhouse);
/* get group id */
buffer_len = sysconf(_SC_GETGR_R_SIZE_MAX);
if (buffer_len == -1)
- {
buffer_len = 16384;
- }
_net_nfc_util_alloc_mem(buffer, buffer_len);
- if (buffer == NULL)
+ if (NULL == buffer)
return false;
getgrnam_r("inhouse", &grp, buffer, buffer_len, &gr_inhouse);
if ((pw_inhouse != NULL) && (gr_inhouse != NULL))
{
if (fchown(fileno(file), pw_inhouse->pw_uid, gr_inhouse->gr_gid) < 0)
- {
NFC_ERR("failed to change owner");
- }
}
return true;
static net_nfc_error_e net_nfc_app_util_store_ndef_message(data_s *data)
{
int ret;
- net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
- char file_name[1024] = { 0, };
FILE *fp = NULL;
+ char file_name[1024] = { 0, };
+ net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
- if (data == NULL)
- {
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
/* check and make directory */
snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_MANAGER_DATA_PATH,
return result;
}
-static bool _net_nfc_app_util_get_operation_from_record(ndef_record_s *record, char *operation, size_t length)
+static bool _net_nfc_app_util_get_operation_from_record(
+ ndef_record_s *record, char *operation, size_t length)
{
bool result = false;
char *op_text = NULL;
- if (record == NULL || operation == NULL || length == 0)
- {
- return result;
- }
+ RETV_IF(NULL == record, result);
+ RETV_IF(NULL == operation, result);
+ RETV_IF(0 == length, result);
switch (record->TNF)
{
_to_lower_utf_8(str);
}
-static bool _net_nfc_app_util_get_mime_from_record(ndef_record_s *record, char *mime, size_t length)
+static bool _net_nfc_app_util_get_mime_from_record(
+ ndef_record_s *record, char *mime, size_t length)
{
bool result = false;
- if (record == NULL || mime == NULL || length == 0)
- {
- return result;
- }
+ RETV_IF(NULL == record, result);
+ RETV_IF(NULL == mime, result);
+ RETV_IF(0 == length, result);
switch (record->TNF)
{
case NET_NFC_RECORD_MIME_TYPE :
{
+ int len = 0;
char *token = NULL;
char *buffer = NULL;
- int len = 0;
if (record->type_s.buffer == NULL || record->type_s.length == 0)
{
/* get mime type */
_net_nfc_util_alloc_mem(buffer, record->type_s.length + 1);
- if (buffer == NULL)
+ if (NULL == buffer)
{
NFC_ERR("_net_nfc_manager_util_alloc_mem return NULL");
break;
token = strchr(buffer, ';');
if (token != NULL)
- {
len = MIN(token - buffer, length - 1);
- }
else
- {
len = MIN(strlen(buffer), length - 1);
- }
strncpy(mime, buffer, len);
mime[len] = '\0';
{
bool result = false;
- if (record == NULL || data == NULL || length == 0)
- {
- return result;
- }
+ RETV_IF(NULL == record, result);
+ RETV_IF(NULL == data, result);
+ RETV_IF(0 == length, result);
switch (record->TNF)
{
{
bool result = false;
- if (record == NULL || data == NULL || length == 0)
- {
- return result;
- }
+ RETV_IF(NULL == record, result);
+ RETV_IF(NULL == data, result);
+ RETV_IF(0 == length, result);
switch (record->TNF)
{
net_nfc_error_e net_nfc_app_util_process_ndef(data_s *data)
{
- net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
- ndef_message_s *msg = NULL;
- char operation[2048] = { 0, };
+ int ret = 0;
char mime[2048] = { 0, };
char text[2048] = { 0, };
+ ndef_message_s *msg = NULL;
+ char operation[2048] = { 0, };
+ net_nfc_error_e result = NET_NFC_UNKNOWN_ERROR;
#ifdef USE_FULL_URI
char uri[2048] = { 0, };
#endif
- int ret = 0;
- if (data == NULL || data->buffer == NULL || data->length == 0)
- {
- NFC_ERR("net_nfc_app_util_process_ndef NET_NFC_NULL_PARAMETER");
- return NET_NFC_NULL_PARAMETER;
- }
+ RETV_IF(NULL == data, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == data->buffer, NET_NFC_NULL_PARAMETER);
+ RETV_IF(NULL == data->length, NET_NFC_NULL_PARAMETER);
/* create file */
if ((result = net_nfc_app_util_store_ndef_message(data)) != NET_NFC_OK)
goto ERROR;
}
- if (_net_nfc_app_util_get_operation_from_record(msg->records, operation, sizeof(operation)) == FALSE)
+ if (_net_nfc_app_util_get_operation_from_record(msg->records, operation,
+ sizeof(operation)) == FALSE)
{
NFC_ERR("_net_nfc_app_util_get_operation_from_record failed [%d]", result);
result = NET_NFC_UNKNOWN_ERROR;
struct stat statbuf = { 0 };
if (stat(path_name, &statbuf) == -1)
- {
return false;
- }
if (S_ISDIR(statbuf.st_mode) != 0)
- {
return true;
- }
else
- {
return false;
- }
}
void net_nfc_app_util_clean_storage(char* src_path)
{
- struct dirent* ent = NULL;
DIR* dir = NULL;
-
char path[1024] = { 0 };
+ struct dirent* ent = NULL;
- if ((dir = opendir(src_path)) == NULL)
- {
- return;
- }
+ RET_IF((dir = opendir(src_path)) == NULL);
while ((ent = readdir(dir)) != NULL)
{
bundle *bd = NULL;
bd = bundle_create();
- if (bd == NULL)
+ if (NULL == bd)
return result;
if (operation != NULL && strlen(operation) > 0)
{
int current = 0;
- if (buffer == NULL || len == 0 || out_buf == NULL || max_len == 0)
- return;
+ RET_IF(0 == len);
+ RET_IF(0 == max_len);
+ RET_IF(NULL == buffer);
+ RET_IF(NULL == out_buf);
while (len > 0 && current < max_len)
{
void _string_to_binary(const char *input, uint8_t *output, uint32_t *length)
{
- int current = 0;
int temp;
+ int current = 0;
- if (input == NULL || *length == 0 || output == NULL)
- return;
-
+ RET_IF(NULL == input);
+ RET_IF(NULL == length);
+ RET_IF(0 == *length);
+ RET_IF(NULL == output);
NFC_DBG("_string_to_binary ");
/* strlen("nfc://secure/aid/") = 17 */
temp -= 7;
if(current % 2)
- {
output[current / 2] += temp;
- }
else
- {
output[current / 2] = temp << 4;
- }
current++;
}
*length = current / 2;
}
-int net_nfc_app_util_launch_se_transaction_app(net_nfc_secure_element_type_e se_type,
- uint8_t *aid, uint32_t aid_len, uint8_t *param, uint32_t param_len)
+int net_nfc_app_util_launch_se_transaction_app(
+ net_nfc_secure_element_type_e se_type,
+ uint8_t *aid,
+ uint32_t aid_len,
+ uint8_t *param,
+ uint32_t param_len)
{
bundle *bd = NULL;
BUF_MEM *bptr;
BIO *b64, *bmem;
- if (buffer == NULL || buf_len == 0 || result == NULL || max_result == 0)
- return ret;
+ RETV_IF(NULL == buffer, ret);
+ RETV_IF(0 == buf_len, ret);
+ RETV_IF(NULL == result, ret);
+ RETV_IF(0 == max_result, ret);
/* base 64 */
b64 = BIO_new(BIO_f_base64());
int ret = -1;
char *temp = NULL;
- if (buffer == NULL || buf_len == 0 || result == NULL || res_len == NULL || *res_len == 0)
- return ret;
+ RETV_IF(NULL == buffer, ret);
+ RETV_IF(0 == buf_len, ret);
+ RETV_IF(NULL == result, ret);
+ RETV_IF(NULL == res_len, ret);
+ RETV_IF(0 == *res_len, ret);
_net_nfc_util_alloc_mem(temp, buf_len);
if (temp != NULL)
pid_t net_nfc_app_util_get_focus_app_pid()
{
- Ecore_X_Window focus;
pid_t pid;
+ Ecore_X_Window focus;
ecore_x_init(":0");
bool net_nfc_app_util_check_launch_state()
{
+ bool result = false;
pid_t focus_app_pid;
net_nfc_launch_popup_state_e popup_state;
- bool result = false;
focus_app_pid = net_nfc_app_util_get_focus_app_pid();
popup_state = net_nfc_server_gdbus_get_client_popup_state(focus_app_pid);
- if(popup_state == NET_NFC_NO_LAUNCH_APP_SELECT)
+ if(NET_NFC_NO_LAUNCH_APP_SELECT == popup_state)
result = true;
return result;
NFC_DBG("_play_sound_callback");
if (WAV_PLAYER_ERROR_NONE != wav_player_stop(id))
- {
NFC_ERR("wav_player_stop failed");
- }
}
void net_nfc_manager_util_play_sound(net_nfc_sound_type_e sound_type)
if (SVI_SUCCESS == svi_init(&svi_handle))
{
if (SVI_SUCCESS == svi_play_vib(svi_handle, SVI_VIB_TOUCH_SIP))
- {
NFC_DBG("svi_play_vib success");
- }
svi_fini(svi_handle);
}
if (sound_path != NULL)
{
- if (WAV_PLAYER_ERROR_NONE == wav_player_start(sound_path, SOUND_TYPE_MEDIA, _play_sound_callback, NULL, NULL))
+ if (WAV_PLAYER_ERROR_NONE ==
+ wav_player_start(sound_path, SOUND_TYPE_MEDIA, _play_sound_callback,
+ NULL, NULL))
{
NFC_DBG("wav_player_start success");
}
/* set predefined item */
result = vconf_set_bool(VCONFKEY_NFC_PREDEFINED_ITEM_STATE, boolval);
if (result != 0)
- {
- NFC_ERR("can not set to %d: %s",
- boolval,
- "VCONKEY_NFC_PREDEFINED_ITEM_STATE");
- }
+ NFC_ERR("can not set to %d: %s", boolval, "VCONKEY_NFC_PREDEFINED_ITEM_STATE");
}
static void net_nfc_server_vconf_pm_state_changed(keynode_t *key,
void *user_data)
{
+ gint result;
gint state = 0;
gint pm_state = 0;
- gint result;
result = vconf_get_bool(VCONFKEY_NFC_STATE, &state);
if (result != 0)
NFC_ERR("can not get %s", "VCONFKEY_NFC_STATE");
- if (state == false)
+ if (false == state)
{
NFC_DBG("NFC off");
return;
NFC_DBG("pm_state : %d", pm_state);
- if (pm_state == VCONFKEY_PM_STATE_NORMAL ||
- pm_state == VCONFKEY_PM_STATE_LCDOFF)
- {
+ if (VCONFKEY_PM_STATE_NORMAL == pm_state || VCONFKEY_PM_STATE_LCDOFF == pm_state)
net_nfc_server_restart_polling_loop();
- }
}
static void net_nfc_server_vconf_flight_mode_changed(keynode_t *key,
void *user_data)
{
- gint flight_mode = 0;
+ gint result = 0;
gint nfc_state = 0;
+ gint flight_mode = 0;
- gint result = 0;
result = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode);
if (result != 0)
- {
- NFC_ERR("Can not get %s",
- "VCONFKEY_TELEPHONY_FLIGHT_MODE");
- }
+ NFC_ERR("Can not get VCONFKEY_TELEPHONY_FLIGHT_MODE");
NFC_DBG("flight mode %d", flight_mode);
result = vconf_get_bool(VCONFKEY_NFC_STATE, &nfc_state);
if (result != 0)
- {
- NFC_ERR("Can not get %s",
- "VCONFKEY_NET_STATE");
- }
+ NFC_ERR("Can not get VCONFKEY_NET_STATE");
NFC_DBG("nfc_state %d", nfc_state);
NFC_DBG("powerd_off_by_flightmode %d", powered_off_by_flightmode);
if (flight_mode) /* turn on flight mode */
{
/* nfc is already disabled ignore it */
- if (nfc_state == VCONFKEY_NFC_STATE_OFF)
+ if (VCONFKEY_NFC_STATE_OFF == nfc_state)
return;
NFC_INFO("Turning NFC off");
else /* turn off flight mode */
{
/* nfc is already enabled, ignre it */
- if (nfc_state == VCONFKEY_NFC_STATE_ON)
+ if (VCONFKEY_NFC_STATE_ON == nfc_state)
return;
- if (powered_off_by_flightmode == FALSE)
+ if (FALSE == powered_off_by_flightmode)
return;
NFC_INFO("Turning NFC on");
void net_nfc_server_vconf_init(void)
{
vconf_notify_key_changed(VCONFKEY_PM_STATE,
- net_nfc_server_vconf_pm_state_changed,
- NULL);
+ net_nfc_server_vconf_pm_state_changed, NULL);
vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
- net_nfc_server_vconf_flight_mode_changed,
- NULL);
+ net_nfc_server_vconf_flight_mode_changed, NULL);
}
void net_nfc_server_vconf_deinit(void)
{
- vconf_ignore_key_changed(VCONFKEY_PM_STATE,
- net_nfc_server_vconf_pm_state_changed);
+ vconf_ignore_key_changed(VCONFKEY_PM_STATE, net_nfc_server_vconf_pm_state_changed);
vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
net_nfc_server_vconf_flight_mode_changed);