#include <sys/stat.h>
#include <pwd.h>
-#define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender"
-
+#include "log.h"
#include "sticker_info.h"
+#define ACCESSORY_SERVICE_PROFILE_ID "/sample/filetransfersender"
+
using namespace std;
struct priv {
{
char error_message[100];
- dlog_print(DLOG_INFO, TAG, "# transfer completed");
+ LOGI("# transfer completed");
if (priv_data.socket) {
sap_file_transfer_destroy(file_transaction);
if (result == SAP_FT_TRANSFER_SUCCESS) {
sprintf(error_message, "Transfer Completed");
- dlog_print(DLOG_INFO, TAG, "Transfer Completed");
+ LOGI("Transfer Completed");
if (chmod(recv_filepath.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) == -1) {
- dlog_print(DLOG_ERROR, TAG, "Failed to change permission : %s. error : %s", recv_filepath.c_str(), strerror(errno));
+ LOGE("Failed to change permission : %s. error : %s", recv_filepath.c_str(), strerror(errno));
}
else {
- dlog_print(DLOG_INFO, TAG, "Succeed to change permission : %s", recv_filepath.c_str());
+ LOGI("Succeed to change permission : %s", recv_filepath.c_str());
if (create_sticker_provider_handle() == STICKER_ERROR_NONE) {
insert_sticker_data(recv_filepath.c_str(), "keyword", "group", "test icon");
destroy_sticker_provider_handle();
if (unlink(recv_filepath.c_str()) == -1)
- dlog_print(DLOG_ERROR, TAG, "Failed to remove sticker file");
+ LOGE("Failed to remove sticker file");
}
}
} else {
switch (result) {
case (SAP_FT_TRANSFER_FAIL_CHANNEL_IO): {
sprintf(error_message, "Channel IO Error.");
- dlog_print(DLOG_WARN, TAG, "Channel IO Error.");
+ LOGW("Channel IO Error.");
break;
}
case (SAP_FT_TRANSFER_FAIL_FILE_IO): {
sprintf(error_message, "File IO Error.");
- dlog_print(DLOG_WARN, TAG, "File IO Error.");
+ LOGW("File IO Error.");
break;
}
case (SAP_FT_TRANSFER_FAIL_CMD_DROPPED): {
sprintf(error_message, "Transfer dropped.");
- dlog_print(DLOG_WARN, TAG, "Transfer dropped.");
+ LOGW("Transfer dropped.");
break;
}
case (SAP_FT_TRANSFER_FAIL_PEER_UNRESPONSIVE): {
sprintf(error_message, "Peer Un Responsive.");
- dlog_print(DLOG_WARN, TAG, "Peer Un Responsive.");
+ LOGW("Peer Un Responsive.");
break;
}
case (SAP_FT_TRANSFER_FAIL_PEER_CONN_LOST): {
sprintf(error_message, "Connection Lost.");
- dlog_print(DLOG_WARN, TAG, "Connection Lost.");
+ LOGW("Connection Lost.");
break;
}
case (SAP_FT_TRANSFER_FAIL_PEER_CANCELLED): {
sprintf(error_message, "Peer Cancelled.");
- dlog_print(DLOG_WARN, TAG, "Peer Cancelled.");
+ LOGW("Peer Cancelled.");
break;
}
case (SAP_FT_TRANSFER_FAIL_SPACE_NOT_AVAILABLE): {
sprintf(error_message, "No Space.");
- dlog_print(DLOG_WARN, TAG, "No Space.");
+ LOGW("No Space.");
break;
}
default:
sprintf(error_message, "Unknown Error");
- dlog_print(DLOG_WARN, TAG, "Unknown Error");
+ LOGW("Unknown Error");
}
}
unsigned short int percentage_progress,
void *user_data)
{
- dlog_print(DLOG_INFO, TAG, "# progress %d", percentage_progress);
+ LOGI("# progress %d", percentage_progress);
}
static void __set_file_transfer_cb(sap_file_transaction_h file_socket)
{
- dlog_print(DLOG_INFO, TAG, "# set callbacks");
+ LOGI("# set callbacks");
sap_file_transfer_set_progress_cb(file_socket, _on_sending_file_in_progress, NULL);
sap_file_transfer_set_done_cb(file_socket, _on_send_completed, NULL);
char *data_path = NULL;
data_path = app_get_shared_data_path();
- dlog_print(DLOG_INFO, TAG, "Path : %s", data_path);
+ LOGI("Path : %s", data_path);
sprintf(file_path, "%s/%s", data_path, incoming_file_name.c_str());
- dlog_print(DLOG_INFO, TAG, "Receive filepath : %s", file_path);
+ LOGI("Receive filepath : %s", file_path);
recv_filepath = string(file_path);
free(data_path);
ret = sap_file_transfer_receive(priv_data.socket, file_path);
switch(ret) {
case SAP_RESULT_PERMISSION_DENIED:
- dlog_print(DLOG_WARN, TAG, "permission denied");
+ LOGW("permission denied");
break;
case SAP_RESULT_FAILURE:
- dlog_print(DLOG_WARN, TAG, "Fail");
+ LOGW("Fail");
break;
case SAP_RESULT_SUCCESS:
- dlog_print(DLOG_INFO, TAG, "Success");
+ LOGI("Success");
break;
}
void reject_file()
{
int ret = sap_file_transfer_reject(priv_data.socket);
- dlog_print(DLOG_INFO, TAG, "ret : %d", ret);
+ LOGI("ret : %d", ret);
file_on_progress = 0;
}
{
file_on_progress = 1;
priv_data.socket = socket;
- dlog_print(DLOG_INFO, TAG, "# incoming file request.");
+ LOGI("# incoming file request.");
__set_file_transfer_cb(priv_data.socket);
incoming_file_name = file_path;
std::size_t found = incoming_file_name.find_last_of("/");
incoming_file_name = incoming_file_name.substr(found+1);
- dlog_print(DLOG_INFO, TAG, "# file path : %s, incoming file name : %s", file_path, incoming_file_name.c_str());
+ LOGI("# file path : %s, incoming file name : %s", file_path, incoming_file_name.c_str());
accept_file();
}
sap_service_connection_terminated_reason_e result,
void *user_data)
{
- dlog_print(DLOG_INFO, TAG, "connection terminated");
+ LOGI("connection terminated");
}
void
on_data_received(sap_socket_h socket, unsigned short int channel_id, unsigned int payload_length, void *buffer,
void *user_data) /* message exchange on_receive callback (sap_agent_data_received_cb) */
{
- dlog_print(DLOG_INFO, TAG, "received data: %s, len:%d", (char *)buffer, payload_length);
+ LOGI("received data: %s, len:%d", (char *)buffer, payload_length);
}
static void on_conn_req(sap_peer_agent_h peer_agent,
switch (result) {
case SAP_AGENT_INITIALIZED_RESULT_SUCCESS:
- dlog_print(DLOG_DEBUG, TAG, "agent is initialized");
+ LOGD("agent is initialized");
priv_data.agent = agent;
break;
case SAP_AGENT_INITIALIZED_RESULT_DUPLICATED:
- dlog_print(DLOG_ERROR, TAG, "duplicate registration");
+ LOGE("duplicate registration");
break;
case SAP_AGENT_INITIALIZED_RESULT_INVALID_ARGUMENTS:
- dlog_print(DLOG_ERROR, TAG, "invalid arguments");
+ LOGE("invalid arguments");
break;
case SAP_AGENT_INITIALIZED_RESULT_INTERNAL_ERROR:
- dlog_print(DLOG_ERROR, TAG, "internal sap error");
+ LOGE("internal sap error");
break;
default:
- dlog_print(DLOG_ERROR, TAG, "unknown status (%d)", result);
+ LOGE("unknown status (%d)", result);
break;
}
sap_transport_type_e transport_type,
void *user_data)
{
- dlog_print(DLOG_DEBUG, TAG, "%s, status :%d", __func__, status);
+ LOGD("%s, status :%d", __func__, status);
switch (transport_type) {
case SAP_TRANSPORT_TYPE_BT:
- dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): bt", transport_type);
+ LOGD("transport_type (%d): bt", transport_type);
break;
case SAP_TRANSPORT_TYPE_BLE:
- dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): ble", transport_type);
+ LOGD("transport_type (%d): ble", transport_type);
break;
case SAP_TRANSPORT_TYPE_TCP:
- dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): tcp/ip", transport_type);
+ LOGD("transport_type (%d): tcp/ip", transport_type);
break;
case SAP_TRANSPORT_TYPE_USB:
- dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): usb", transport_type);
+ LOGD("transport_type (%d): usb", transport_type);
break;
case SAP_TRANSPORT_TYPE_MOBILE:
- dlog_print(DLOG_DEBUG, TAG, "transport_type (%d): mobile", transport_type);
+ LOGD("transport_type (%d): mobile", transport_type);
break;
default:
- dlog_print(DLOG_ERROR, TAG, "unknown transport_type (%d)", transport_type);
+ LOGE("unknown transport_type (%d)", transport_type);
break;
}
switch (status) {
case SAP_DEVICE_STATUS_DETACHED:
- dlog_print(DLOG_DEBUG, TAG, "device is not connected.");
+ LOGD("device is not connected.");
break;
case SAP_DEVICE_STATUS_ATTACHED:
- dlog_print(DLOG_DEBUG, TAG, "Attached calling find peer now");
+ LOGD("Attached calling find peer now");
break;
default:
- dlog_print(DLOG_ERROR, TAG, "unknown status (%d)", status);
+ LOGE("unknown status (%d)", status);
break;
}
}
result = sap_agent_initialize(priv_data.agent, ACCESSORY_SERVICE_PROFILE_ID, SAP_AGENT_ROLE_CONSUMER,
on_agent_initialized, NULL);
- dlog_print(DLOG_DEBUG, TAG, "SAP >>> getRegisteredServiceAgent() >>> %d", result);
+ LOGD("SAP >>> getRegisteredServiceAgent() >>> %d", result);
} while (result != SAP_RESULT_SUCCESS);
return TRUE;
#include "sticker_info.h"
#include <sticker_provider.h>
-#include <dlog.h>
#include <app_common.h>
#include <stdio.h>
#include <stdlib.h>
+#include "log.h"
+
static sticker_provider_h sticker_provider = NULL;
sticker_data_h
ret = sticker_data_create(&sticker_data);
if (ret != STICKER_ERROR_NONE) {
/* Error handling */
- dlog_print(DLOG_ERROR, TAG, "Failed to create sticker data");
+ LOGE("Failed to create sticker data");
}
/* Sets the URI and URI type of the sticker */
ret = sticker_data_set_uri(sticker_data, type, uri);
if (ret != STICKER_ERROR_NONE) {
/* Error handling */
- dlog_print(DLOG_ERROR, TAG, "Failed to set uri");
+ LOGE("Failed to set uri");
}
//for (int i = 0; i < len; i++)
ret = sticker_data_add_keyword(sticker_data, keyword);
if (ret != STICKER_ERROR_NONE) {
/* Error handling */
- dlog_print(DLOG_ERROR, TAG, "Failed to add keyword");
+ LOGE("Failed to add keyword");
}
}
ret = sticker_data_set_group_name(sticker_data, group);
if (ret != STICKER_ERROR_NONE) {
/* Error handling */
- dlog_print(DLOG_ERROR, TAG, "Failed to set group name");
+ LOGE("Failed to set group name");
}
/* Sets the thumbnail local path of the sticker */
ret = sticker_data_set_thumbnail(sticker_data, thumbnail);
if (ret != STICKER_ERROR_NONE) {
/* Error handling */
- dlog_print(DLOG_ERROR, TAG, "Failed to set thumbnail");
+ LOGE("Failed to set thumbnail");
}
}
ret = sticker_data_set_description(sticker_data, description);
if (ret != STICKER_ERROR_NONE) {
/* Error handling */
- dlog_print(DLOG_ERROR, TAG, "Failed to set description");
+ LOGE("Failed to set description");
}
return sticker_data;
ret = sticker_provider_insert_data(sticker_provider, data_handle);
if (ret != STICKER_ERROR_NONE) {
- dlog_print(DLOG_ERROR, TAG, "Failed to insert data. error code : %x. message : %s", ret, get_error_message(ret));
+ LOGE("Failed to insert data. error code : %x. message : %s", ret, get_error_message(ret));
}
else {
- dlog_print(DLOG_INFO, TAG, "Succeeded to insert data");
+ LOGI("Succeeded to insert data");
}
/* Destroys a sticker data handle */
ret = sticker_data_destroy(data_handle);
if (ret != STICKER_ERROR_NONE) {
/* Error handling */
- dlog_print(DLOG_ERROR, TAG, "Failed to destroy sticker data");
+ LOGE("Failed to destroy sticker data");
}
}
ret = sticker_provider_create(&sticker_provider);
if (ret != STICKER_ERROR_NONE) {
/* Error handling */
- dlog_print(DLOG_ERROR, TAG, "Failed to create sticker provider");
+ LOGE("Failed to create sticker provider");
}
return ret;