char mac[UAM_MAC_ADDRESS_STRING_LEN]; /**< Device's MAC ADDRESS */
char ipv4_addr[UAM_IP_ADDRESS_MAX_STRING_LEN];/**< Device's IPv4 address optional */
char device_id[UAM_DEVICE_ID_MAX_STRING_LEN]; /**< Device's uniquie ID */
+ gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
long last_seen; /**< Latest timestamp when device was discoverd */
} uam_device_info_s;
*/
int _uam_get_service_detection_cycle(const char *service, unsigned int *cycle);
+/**
+ * @brief Resets contents in database.
+ * @since_tizen 5.5
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UAM_ERROR_NONE Successful
+ * @retval #UAM_ERROR_INTERNAL Internal error
+ *
+ * @exception
+ * @pre
+ * @post
+ */
int _uam_db_reset(void);
+/**
+ * @brief Sets the device to determine whether to detect.
+ * @since_tizen 5.5
+ *
+ * @param[in] dev_info Device information.
+ * @param[in] discriminant Whether to detect this device or not
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UAM_ERROR_NONE Successful
+ * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
+ * @retval #UAM_ERROR_INTERNAL Internal error
+ *
+ * @exception
+ * @pre
+ * @post
+ */
+int _uam_request_set_device_discriminant(const char *mac, gboolean discriminant);
+
+/**
+ * @brief Sets the device to determine whether to detect.
+ * @since_tizen 5.5
+ *
+ * @param[in] dev_info Device information.
+ * @param[out] discriminant Whether to detect this device or not
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UAM_ERROR_NONE Successful
+ * @retval #UAM_ERROR_INVALID_PARAMETER Invalid parameters
+ * @retval #UAM_ERROR_INTERNAL Internal error
+ *
+ * @exception
+ * @pre
+ * @post
+ */
+int _uam_request_get_device_discriminant(const char *mac, gboolean *discriminant);
+
#ifdef __cplusplus
}
#endif
REQUEST(UAM_REQUEST_GET_SERVICE_DEVICES) \
REQUEST(UAM_REQUEST_GET_SERVICE_USERS) \
REQUEST(UAM_REQUEST_GET_SERVICES) \
+ REQUEST(UAM_REQUEST_GET_DEVICE_DISCRIMINANT) \
+ REQUEST(UAM_REQUEST_SET_DEVICE_DISCRIMINANT) \
REQUEST(UAM_REQUEST_MAX)
#define GENERATE_REQUEST_ENUM(ENUM) ENUM,
return ret;
}
-UAM_EXPORT_API int _uam_is_device_registered(uam_device_info_s *dev_info, gboolean *is_registered)
+UAM_EXPORT_API int _uam_is_device_registered(uam_device_info_s *dev_info,
+ gboolean *is_registered)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_request_get_user_devices(char *account, GPtrArray **devices_list)
+UAM_EXPORT_API int _uam_request_get_user_devices(char *account,
+ GPtrArray **devices_list)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_request_set_detection_threshold(unsigned int sensor_type, int presence_threshold, int absence_threshold)
+UAM_EXPORT_API int _uam_request_set_detection_threshold(
+ unsigned int sensor_type, int presence_threshold, int absence_threshold)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_start_presence_detection(unsigned int bitmask, const char *service)
+UAM_EXPORT_API int _uam_start_presence_detection(unsigned int bitmask,
+ const char *service)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_stop_presence_detection(unsigned int bitmask, const char *service)
+UAM_EXPORT_API int _uam_stop_presence_detection(unsigned int bitmask,
+ const char *service)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_start_absence_detection(unsigned int bitmask, const char *service)
+UAM_EXPORT_API int _uam_start_absence_detection(unsigned int bitmask,
+ const char *service)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_stop_absence_detection(unsigned int bitmask, const char *service)
+UAM_EXPORT_API int _uam_stop_absence_detection(unsigned int bitmask,
+ const char *service)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_start_search_active_devices(unsigned int bitmask, int detection_period)
+UAM_EXPORT_API int _uam_start_search_active_devices(unsigned int bitmask,
+ int detection_period)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_service_remove_user(const char *service, const char *account)
+UAM_EXPORT_API int _uam_service_remove_user(const char *service,
+ const char *account)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_service_add_device(const char *service, char *device_id, uam_tech_type_e tech_type)
+UAM_EXPORT_API int _uam_service_add_device(const char *service, char *device_id,
+ uam_tech_type_e tech_type)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_service_remove_device(const char *service, char *device_id, uam_tech_type_e tech_type)
+UAM_EXPORT_API int _uam_service_remove_device(const char *service,
+ char *device_id, uam_tech_type_e tech_type)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_set_service_detection_cycle(const char *service, unsigned int cycle)
+UAM_EXPORT_API int _uam_set_service_detection_cycle(const char *service,
+ unsigned int cycle)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_get_service_detection_cycle(const char *service, unsigned int *cycle)
+UAM_EXPORT_API int _uam_get_service_detection_cycle(const char *service,
+ unsigned int *cycle)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_request_get_service_devices(char *svc_name, GPtrArray **devices_list)
+UAM_EXPORT_API int _uam_request_get_service_devices(char *svc_name,
+ GPtrArray **devices_list)
{
FUNC_ENTRY;
int ret;
return ret;
}
-UAM_EXPORT_API int _uam_request_get_service_users(char *svc_name, GPtrArray **users_list)
+UAM_EXPORT_API int _uam_request_get_service_users(char *svc_name,
+ GPtrArray **users_list)
{
FUNC_ENTRY;
int ret;
FUNC_EXIT;
return ret;
}
+
+UAM_EXPORT_API int _uam_request_set_device_discriminant(
+ const char *mac, gboolean discriminant)
+{
+ FUNC_ENTRY;
+ int ret;
+ char str[UAM_MAC_ADDRESS_STRING_LEN + 1] = {0, };
+ int tmp = discriminant ? 1 : 0;
+
+ UAM_VALIDATE_INPUT_PARAMETER(mac);
+
+ UAM_INIT_PARAMS();
+ UAM_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_strlcpy(str, mac, UAM_MAC_ADDRESS_STRING_LEN);
+ g_array_append_vals(in_param1, str, sizeof(str));
+ g_array_append_vals(in_param2, &tmp, sizeof(int));
+
+ ret = _uam_sync_request(UAM_REQUEST_SET_DEVICE_DISCRIMINANT,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ FUNC_EXIT;
+ return ret;
+}
+
+UAM_EXPORT_API int _uam_request_get_device_discriminant(
+ const char *mac, gboolean *discriminant)
+{
+ FUNC_ENTRY;
+ int ret;
+ char str[UAM_MAC_ADDRESS_STRING_LEN + 1] = {0, };
+ int tmp = 0;
+
+ UAM_VALIDATE_INPUT_PARAMETER(mac);
+
+ UAM_INIT_PARAMS();
+ UAM_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_strlcpy(str, mac, UAM_MAC_ADDRESS_STRING_LEN);
+ g_array_append_vals(in_param1, str, sizeof(str));
+
+ ret = _uam_sync_request(UAM_REQUEST_GET_DEVICE_DISCRIMINANT,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+ if (UAM_ERROR_NONE == ret)
+ tmp = g_array_index(out_param, int, 0);
+
+ *discriminant = tmp ? TRUE : FALSE;
+
+ UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ FUNC_EXIT;
+ return ret;
+}
\ No newline at end of file
timestamp LONG,
presence_state INTEGER,
os_type INTEGER,
+ discriminant INTETER,
FOREIGN KEY(user_id) REFERENCES userdata(user_id),
PRIMARY KEY(device_id, tech_type, address)
);
GSList *addresses;
int presence_state;
long timestamp;
+ gboolean discriminant;
struct uam_db_device_info *device;
GSList *svc_list;
} uam_db_tech_info_t;
// int presence_state;
// long timestamp;
struct uam_db_user_info *user;
+ gboolean discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
} uam_db_device_info_t;
typedef struct uam_db_user_info {
int _uam_core_get_service_detection_cycle(const char *svc_name, unsigned int *cycle);
+int _uam_core_set_devcie_discriminant(const char *mac, gboolean discriminant);
+
+int _uam_core_get_devcie_discriminant(const char *mac, gboolean *discriminant);
+
#ifdef __cplusplus
}
#endif
int presence_state);
int _ua_device_db_update_device_ip_address(char *device_id, int tech_type, char *address,
char *ip_address);
-
+int _ua_device_db_update_device_discriminant(char *device_id, int tech_type,
+ char *address, char discriminant);
/* SERVICE QUERIES */
typedef struct {
retv_if(NULL == dev, NULL);
device = g_new0(uas_device_info_t, 1);
+ retv_if(NULL == device, NULL);
+
device->os = dev->operating_system;
+ device->discriminant = dev->discriminant;
if (0 < strlen(dev->mac)) {
switch (dev->type) {
retv_if(NULL == dev, NULL);
device = g_new0(uam_device_info_s, 1);
+ retv_if(NULL == device, NULL);
+
device->operating_system = dev->os;
+ device->discriminant = dev->discriminant;
g_strlcpy(device->device_id, dev->device_id, UAM_DEVICE_ID_MAX_STRING_LEN);
(*device_list)[indx].operating_system = db_info->os;
g_strlcpy((*device_list)[indx].device_id, db_info->device_id,
UAM_DEVICE_ID_MAX_STRING_LEN);
+ (*device_list)[indx].discriminant = tech->discriminant;
(*device_list)[indx].last_seen = tech->timestamp;
(*device_list)[indx++].type = tech->tech_type;
}
g_strlcpy(device->device_id, tech->device->device_id,
UAM_DEVICE_ID_MAX_STRING_LEN);
device->type = tech->tech_type;
+ device->discriminant= tech->discriminant;
FUNC_EXIT;
return UAM_ERROR_NONE;
tech->presence_state = presence_state;
tech->timestamp = timestamp;
tech->device = device;
+ tech->discriminant = dev_info->discriminant;
tech->svc_list = svc_list;
g_slist_foreach(tech->svc_list, __print_service, tech);
g_strlcpy(device->device_id, db_info->device_id,
UAM_DEVICE_ID_MAX_STRING_LEN);
device->type = tech->tech_type;
+ device->discriminant = tech->discriminant;
}
retv_if(UAM_TECH_TYPE_NONE == device->type, UAM_ERROR_NOT_FOUND);
return UAM_ERROR_NONE;
}
+int _uam_core_set_devcie_discriminant(const char *mac, gboolean discriminant)
+{
+ FUNC_ENTRY;
+
+ int ret;
+ GSList *l, *l1;
+
+ uam_db_user_info_t *user;
+ uam_db_device_info_t *device;
+ uam_db_tech_info_t *tech;
+
+ uam_device_info_s dev_info;
+
+ retv_if(NULL == mac, UAM_ERROR_INVALID_PARAMETER);
+
+ /* Get tech device info by using MAC address */
+ tech = __get_tech_info_by_mac(mac);
+ retv_if(NULL == tech, UAM_ERROR_NOT_FOUND);
+ device = tech->device;
+
+ ret = __copy_tech_info_to_device_info(tech, &dev_info);
+ if (UAM_ERROR_NONE != ret) {
+ UAM_ERR("__copy_tech_info_to_device_info failed");
+ return UAM_ERROR_INTERNAL;
+ }
+
+ /* Find all tech-devices in users' devices */
+ for (l = users; NULL != l; l = g_slist_next(l)) {
+ user = l->data;
+
+ l1 = g_slist_find_custom(user->devices,
+ dev_info.device_id, __compare_device_id);
+ if (NULL == l) {
+ UAM_ERR("Valid user_id [%d] but Invalid device_id [%s]",
+ user->user_id, dev_info.device_id);
+ continue;
+ }
+
+ device = l1->data;
+ if (!(device->supported_techs & dev_info.type)) {
+ UAM_ERR("Valid device_id [%s] but Invalid tech type [%d]",
+ dev_info.device_id, dev_info.type);
+ continue;
+ }
+
+ l1 = g_slist_find_custom(device->tech_list,
+ &(dev_info.type), __compare_tech_type);
+ if (NULL == l) {
+ UAM_ERR("device->tech_list, tech type [%d] not found", dev_info.type);
+ continue;
+ }
+
+ tech = l1->data;
+ if (!tech) {
+ UAM_ERR("Device tech, tech type [%d] not found", dev_info.type);
+ continue;
+ }
+ /* Set discriminant */
+ tech->discriminant = discriminant;
+
+ /* Update device's discriminant to database */
+ if (UAM_ERROR_NONE != _ua_device_db_update_device_discriminant(
+ dev_info.device_id, dev_info.type, dev_info.mac, discriminant))
+ UAM_WARN("_ua_device_db_update_device_discriminant failed");
+ }
+
+ FUNC_EXIT;
+ return UAM_ERROR_NONE;
+}
+
+int _uam_core_get_devcie_discriminant(const char *mac, gboolean* discriminant)
+{
+ FUNC_ENTRY;
+
+ int ret;
+ uam_db_tech_info_t *tech;
+ uam_device_info_s dev_info;
+
+ retv_if(NULL == mac, UAM_ERROR_INVALID_PARAMETER);
+
+ tech = __get_tech_info_by_mac(mac);
+ retv_if(NULL == tech, UAM_ERROR_NOT_FOUND);
+
+ ret = __copy_tech_info_to_device_info(tech, &dev_info);
+ if (UAM_ERROR_NONE != ret) {
+ UAM_ERR("__copy_tech_info_to_device_info failed");
+ return UAM_ERROR_INTERNAL;
+ }
+
+ *discriminant = dev_info.discriminant;
+
+ UAM_DBG("DeviceId [%s], Discriminant [%s]", dev_info.device_id,
+ dev_info.discriminant ? "true" : "false");
+ FUNC_EXIT;
+ return UAM_ERROR_NONE;
+
+}
+
int _uam_core_init(void)
{
FUNC_ENTRY;
g_strlcpy((*device_list)[indx].device_id, db_info->device_id,
UAM_DEVICE_ID_MAX_STRING_LEN);
(*device_list)[indx].last_seen = tech->timestamp;
+ (*device_list)[indx].discriminant = tech->discriminant;
(*device_list)[indx++].type = tech->tech_type;
}
#define INSERT_DEVICE "insert into devices " \
"(device_id, tech_type, address, ip_address, timestamp, " \
- "presence_state, os_type, user_id, device_number)" \
- "values (?, ?, ?, ?, ?, ?, ?, ?, ?)"
+ "presence_state, os_type, user_id, discriminant, device_number)" \
+ "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
#define UPDATE_TIMESTAMP "UPDATE devices " \
"SET timestamp = ? WHERE device_id = ? AND tech_type = ? AND address = ?"
"SET presence_state = ? WHERE device_id = ? AND tech_type = ? AND address = ?"
#define UPDATE_IP_ADDRESS "UPDATE devices " \
"SET ip_address = ? WHERE device_id = ? AND tech_type = ? AND address = ?"
+#define UPDATE_DISCRIMINANT "UPDATE devices " \
+ "SET discriminant = ? WHERE device_id = ? AND tech_type = ? AND address = ?"
#define DELETE_ALL_DEVICES "delete from devices "
static sqlite3_stmt *update_timestamp;
static sqlite3_stmt *update_presence;
static sqlite3_stmt *update_ip_address;
+static sqlite3_stmt *update_discriminant;
/* INSERT statements */
static sqlite3_stmt *insert_device_info;
PREPARE_UPDATE(update_timestamp, UPDATE_TIMESTAMP);
PREPARE_UPDATE(update_presence, UPDATE_PRESENCE);
PREPARE_UPDATE(update_ip_address, UPDATE_IP_ADDRESS);
+ PREPARE_UPDATE(update_discriminant, UPDATE_DISCRIMINANT);
initialized = 1;
FUNC_EXIT;
FINALIZE(update_timestamp);
FINALIZE(update_presence);
FINALIZE(update_ip_address);
+ FINALIZE(update_discriminant);
FUNC_EXIT;
}
return error_code;
}
+int _ua_device_db_update_device_discriminant(char *device_id, int tech_type,
+ char *address, char discriminant)
+{
+ int error_code = UAM_ERROR_NONE;
+ sqlite3_stmt *stmt = update_discriminant;
+
+ retv_if(NULL == device_id, UAM_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == address, UAM_ERROR_INVALID_PARAMETER);
+
+ DB_ACTION(sqlite3_bind_int(stmt, 1, discriminant));
+ DB_ACTION(sqlite3_bind_text(stmt, 2, device_id, -1, SQLITE_TRANSIENT));
+ DB_ACTION(sqlite3_bind_int(stmt, 3, tech_type));
+ DB_ACTION(sqlite3_bind_text(stmt, 4, address, -1, SQLITE_TRANSIENT));
+
+ if (sqlite3_step(stmt) != SQLITE_DONE) {
+ UAM_ERR("Failed to update device discriminant: %s",
+ sqlite3_errmsg(__ua_device_db_get_database()));
+
+ error_code = UAM_ERROR_DB_FAILED;
+ goto handle_error;
+ }
+
+ UAM_DBG("Device discriminant updated [%s]", discriminant ? "true" : "false");
+
+handle_error:
+ sqlite3_reset(stmt);
+ return error_code;
+}
+
int _ua_device_db_insert_device_info(int user_id, const uam_device_info_s *dev_info,
int presence_state, long timestamp)
{
retv_if(NULL == dev_info, UAM_ERROR_INVALID_PARAMETER);
- UAM_INFO("%s-%d-%s-%s-%ld-%d-%d-%d", dev_info->device_id,
+ UAM_INFO("%s-%d-%s-%s-%ld-%d-%d-%d-%d", dev_info->device_id,
dev_info->type, dev_info->mac, dev_info->ipv4_addr,
- timestamp, presence_state, dev_info->operating_system, user_id);
+ timestamp, presence_state, dev_info->operating_system, dev_info->discriminant,
+ user_id);
DB_ACTION(sqlite3_bind_text(stmt, 1, dev_info->device_id, -1, SQLITE_TRANSIENT));
DB_ACTION(sqlite3_bind_int(stmt, 2, dev_info->type));
DB_ACTION(sqlite3_bind_int64(stmt, 5, timestamp));
DB_ACTION(sqlite3_bind_int(stmt, 6, presence_state));
DB_ACTION(sqlite3_bind_int(stmt, 7, dev_info->operating_system));
- DB_ACTION(sqlite3_bind_int(stmt, 8, user_id));
- DB_ACTION(sqlite3_bind_int(stmt, 9, max_device_number + 1));
+ DB_ACTION(sqlite3_bind_int(stmt, 9, user_id));
+ DB_ACTION(sqlite3_bind_int(stmt, 10, dev_info->discriminant));
+ DB_ACTION(sqlite3_bind_int(stmt, 11, max_device_number + 1));
if (sqlite3_step(stmt) != SQLITE_DONE) {
UAM_ERR("Failed to insert device info: %s",
}
break;
}
+ case UAM_REQUEST_SET_DEVICE_DISCRIMINANT: {
+ const char *mac;
+ gboolean discriminant = FALSE;
+ int tmp = 0;
+
+ mac = (char *)g_variant_get_data(in_param1);
+ __uam_manager_copy_params(in_param2, &tmp, sizeof(int));
+ discriminant = tmp ? TRUE : FALSE;
+ UAM_DBG("mac: [%s] discriminant: [%s]", mac, discriminant ? "true" : "false");
+
+ result = _uam_core_set_devcie_discriminant(mac, discriminant);
+ break;
+ }
+ case UAM_REQUEST_GET_DEVICE_DISCRIMINANT: {
+ const char *mac;
+ gboolean discriminant;
+ int tmp = 0;
+
+ mac = (char *)g_variant_get_data(in_param1);
+
+ result = _uam_core_get_devcie_discriminant(mac, &discriminant);
+ if (UAM_ERROR_NONE == result)
+ UAM_DBG("mac: [%s] discriminant: [%s]", mac, discriminant ? "true" : "false");
+
+ tmp = discriminant ? 1 : 0;
+ g_array_append_vals(*out_param1, &tmp, sizeof(int));
+ break;
+ }
default:
UAM_WARN("UnSupported function [%s(0x%4.4X)]",
_uam_manager_request_to_str(function), function);
account = (char *)g_variant_get_data(in_param1);
__uam_manager_copy_params(in_param2,
&dev_info, sizeof(uam_device_info_s));
- UAM_DBG("Account: [%s], Type: %d, MAC: [%s] IP: [%s], ID: [%s]",
+ UAM_DBG("Account: [%s], Type: %d, MAC: [%s] IP: [%s], ID: [%s], Discriminant: [%s]",
account, dev_info.type, dev_info.mac,
- dev_info.ipv4_addr, dev_info.device_id);
+ dev_info.ipv4_addr, dev_info.device_id,
+ dev_info.discriminant ? "true" : "false");
result = _uam_core_add_device(account, &dev_info);
if (UAM_ERROR_NONE == result) {
case UAM_REQUEST_GET_SERVICE_DEVICES:
case UAM_REQUEST_GET_SERVICE_USERS:
case UAM_REQUEST_GET_SERVICES:
+ case UAM_REQUEST_SET_DEVICE_DISCRIMINANT:
+ case UAM_REQUEST_GET_DEVICE_DISCRIMINANT:
return TRUE;
default:
return FALSE;
int os;
int num_addr;
uas_address_info_t *addr_list;
+ char discriminant; /**< Determines whether to judge PRESENCE/ABSENCE */
} uas_device_info_t;
/* Active scan event types */