ret = __copy_tech_info_to_device_info(tech, &dev_info);
if (UAM_ERROR_NONE != ret) {
UAM_ERR("__copy_tech_info_to_device_info failed");
+ __uam_db_end_transaction(0);
return ret;
}
return NULL;
}
-static void __get_uam_db_dev_list_to_uam_dev_list(
+static int __get_uam_db_dev_list_to_uam_dev_list(
GSList *db_dev_list, uam_device_info_s **device_list, int *count)
{
FUNC_ENTRY;
GSList *l;
int indx = 0;
+ int ret = UAM_ERROR_NONE;
*count = 0;
/* Calculate num devices first */
for (l = db_dev_list; NULL != l; l = g_slist_next(l)) {
uam_db_device_info_t *db_info = l->data;
GSList *l1;
- int ret;
if (!db_info || !db_info->device_id)
continue;
ret = __copy_tech_info_to_device_info(tech, &((*device_list)[indx]));
if (UAM_ERROR_NONE != ret) {
UAM_ERR("__copy_tech_info_to_device_info failed");
+ return ret;
}
indx++;
}
UAM_INFO("Count = %d, indx = %d", *count, indx);
FUNC_EXIT;
+ return ret;
}
static uam_monitor_info_t *__uam_find_monitor(GSList *monitor_list,
FUNC_ENTRY;
GSList *l;
uam_db_user_info_t *user;
+ int ret = UAM_ERROR_NONE;
l = g_slist_find_custom(users, account, __compare_user_account);
retv_if((NULL != l) && (l->data != NULL), UAM_ERROR_ALREADY_REGISTERED);
user = g_new0(uam_db_user_info_t, 1);
/* Add user to database */
- if (UAM_ERROR_NONE != _uam_db_insert_user_info(&(user->user_id), name, account)) {
- UAM_ERR("_uam_db_insert_user_info failed");
+ ret = _uam_db_insert_user_info(&(user->user_id), name, account);
+ if (UAM_ERROR_NONE != ret) {
+ UAM_ERR("_uam_db_insert_user_info failed [%d]", ret);
g_free(user);
- return UAM_ERROR_DB_FAILED;
+ return ret;
}
user->name = g_strdup(name);
/* Send device removed event to application */
__send_device_event(ret, UAM_EVENT_DEVICE_REMOVED, dev_info);
+ retv_if(UAM_ERROR_NONE != __uam_db_begin_transaction(), UAM_ERROR_DB_FAILED);
/* Remove device from database */
- if (UAM_ERROR_NONE != _uam_device_db_delete_device_info(
- dev_info->device_id, dev_info->type, dev_info->mac))
+ ret = _uam_device_db_delete_device_info(
+ dev_info->device_id, dev_info->type, dev_info->mac);
+ if (UAM_ERROR_NONE != ret) {
UAM_ERR("_uam_device_db_delete_device_info failed");
+ __uam_db_end_transaction(0);
+ return ret;
+ }
/* Remove device from service */
for (l = tech->svc_list; l; l = g_slist_next(l)) {
if (!svc || !svc->name)
continue;
- _uam_core_service_remove_device(svc->name, dev_info->device_id, dev_info->type);
+ ret = _uam_core_service_remove_device(svc->name,
+ dev_info->device_id, dev_info->type);
+ if (UAM_ERROR_NONE != ret) {
+ UAM_ERR("_uam_device_db_delete_device_info failed");
+ __uam_db_end_transaction(0);
+ return ret;
+ }
}
+ __uam_db_end_transaction(1);
/* Remove tech info from device's tech list */
device->tech_list = g_slist_remove(device->tech_list, tech);
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;
+ return ret;
}
ret = __uam_remove_device(device->user->user_id, device, &dev_info, tech);
{
FUNC_ENTRY;
- int ret;
+ int ret = UAM_ERROR_NONE;
GSList *l, *l1, *l2;
uam_device_info_s temp;
tech->payload->bt_mac = g_memdup(&(a_device->payload.bt_mac), UAM_BT_MAC_ADDRESS_STRING_LEN);
/* Update device's updated information to database */
- __copy_tech_info_to_device_info(tech, &temp);
+ ret = __copy_tech_info_to_device_info(tech, &temp);
+ if (UAM_ERROR_NONE != ret) {
+ UAM_ERR("__copy_tech_info_to_device_info failed [%d]", ret);
+ return ret;
+ }
ret = _uam_device_db_update_device_device(temp.device_id, temp.type,
temp.mac, temp.ipv4_addr, temp.operating_system, temp.discriminant,
temp.payload);
- if (UAM_ERROR_NONE != ret)
- UAM_WARN("_uam_device_db_update_device_device failed [%d]", ret);
+ if (UAM_ERROR_NONE != ret) {
+ UAM_ERR("_uam_device_db_update_device_device failed [%d]", ret);
+ return ret;
+ }
}
/* Set/update registered device list to plugins */
ret = _uam_pm_set_registered_devices(devices);
- if (UAM_ERROR_NONE != ret)
+ if (UAM_ERROR_NONE != ret) {
UAM_ERR("_uam_pm_set_registered_devices failed [%d]", ret);
+ return ret;
+ }
/* Set/update registered device list to cloud plugin */
_uam_cloud_update_registered_devices();
FUNC_EXIT;
- return UAM_ERROR_NONE;
+ return ret;
}
int _uam_core_get_default_user(uam_user_info_s *user_info)
ret = __copy_tech_info_to_device_info(tech, device);
if (UAM_ERROR_NONE != ret) {
UAM_ERR("__copy_tech_info_to_device_info failed");
- return UAM_ERROR_INTERNAL;
+ return ret;
}
FUNC_EXIT;
- return UAM_ERROR_NONE;
+ return ret;
}
int _uam_core_get_user_by_device_id(const char *device_id, uam_user_info_s *user)
int _uam_core_get_devices(int *count, uam_device_info_s **device_list)
{
FUNC_ENTRY;
+ int ret = UAM_ERROR_NONE;
- __get_uam_db_dev_list_to_uam_dev_list(devices, device_list, count);
+ ret = __get_uam_db_dev_list_to_uam_dev_list(devices, device_list, count);
FUNC_EXIT;
- return UAM_ERROR_NONE;
+ return ret;
}
int _uam_core_get_user_devices(const char *account,
FUNC_ENTRY;
uam_db_user_info_t *user;
GSList *l;
+ int ret = UAM_ERROR_NONE;
l = g_slist_find_custom(users, account, __compare_user_account);
retv_if(NULL == l, UAM_ERROR_INVALID_PARAMETER);
user = l->data;
- __get_uam_db_dev_list_to_uam_dev_list(user->devices, device_list, count);
+ ret = __get_uam_db_dev_list_to_uam_dev_list(user->devices, device_list, count);
FUNC_EXIT;
- return UAM_ERROR_NONE;
+ return ret;
}
int _uam_core_get_available_sensors(unsigned int *sensor_bitmask)
GSList *l;
char *mac;
uam_db_tech_info_t *tech_info;
+ int ret = UAM_ERROR_NONE;
retv_if(NULL == svc_name, UAM_ERROR_INVALID_PARAMETER);
retv_if(NULL == device_id, UAM_ERROR_INVALID_PARAMETER);
mac = __get_mac_addr(tech_info);
/* Remove service-device from DB */
- if (UAM_ERROR_NONE != _uam_db_delete_device_service_info(
- device_id, tech_type, mac, svc_name))
- UAM_WARN("Device service removal from persistent DB failed");
+ ret = _uam_db_delete_device_service_info(
+ device_id, tech_type, mac, svc_name);
+ if (UAM_ERROR_NONE != ret) {
+ UAM_ERR("Device service removal from persistent DB failed");
+ return ret;
+ }
FUNC_EXIT;
return UAM_ERROR_NONE;
__uam_core_add_dev_to_list(user, dev_info,
UAM_PRESENCE_STATE_PRESENT, timestamp, svc_list);
+ retv_if(UAM_ERROR_NONE != __uam_db_begin_transaction(), UAM_ERROR_DB_FAILED);
/* Add device to database */
ret = _uam_device_db_insert_device_info(user->user_id,
dev_info, UAM_PRESENCE_STATE_PRESENT, timestamp);
if (UAM_ERROR_NONE != ret) {
UAM_WARN("Device addition to persistent DB failed");
+ __uam_db_end_transaction(0);
return ret;
}
if (UAM_ERROR_NONE != ret) {
UAM_WARN("Device service addition to persistent DB failed");
__send_device_event(ret, UAM_EVENT_DEVICE_ADDED, dev_info);
+ __uam_db_end_transaction(0);
return ret;
}
+ __uam_db_end_transaction(1);
ret = _uam_core_update_svc_dev_info(
dev_info->device_id, dev_info->type,
return UAM_ERROR_NONE;
}
-static void __get_service_dev_list(
+static int __get_service_dev_list(
uam_db_service_info_t* service, uam_device_info_s **device_list, int *count)
{
FUNC_ENTRY;
GSList *l1;
int indx = 0;
+ int ret = UAM_ERROR_NONE;
*count = 0;
/* Calculate number of devices */
/* Copy devices */
for (l1 = service->dev_techs; NULL != l1; l1 = g_slist_next(l1)) {
uam_db_tech_info_t *tech = l1->data;
- int ret;
if (!tech || !tech->addresses)
continue;
ret = __copy_tech_info_to_device_info(tech, &((*device_list)[indx]));
if (UAM_ERROR_NONE != ret) {
UAM_ERR("__copy_tech_info_to_device_info failed");
+ return ret;
}
indx++;
}
UAM_INFO("Count = %d, indx = %d", *count, indx);
FUNC_EXIT;
+ return ret;
}
int _uam_core_get_service_devices(const char *svc_name,
FUNC_ENTRY;
uam_db_service_info_t *service;
GSList *l;
+ int ret = UAM_ERROR_NONE;
l = g_slist_find_custom(services, svc_name, __compare_svc_name);
retv_if(NULL == l, UAM_ERROR_INVALID_PARAMETER);
service = l->data;
- __get_service_dev_list(service, device_list, count);
+ ret = __get_service_dev_list(service, device_list, count);
FUNC_EXIT;
- return UAM_ERROR_NONE;
+ return ret;
}
static void __get_service_user_list(