static int add_device(const char *account, uap_device_info_t *dev_info)
{
FUNC_ENTRY;
+ int ret;
uam_device_info_s device;
uam_user_info_s user;
memset(&device, 0x00, sizeof(uam_device_info_s));
__uap_to_uam_device_info(&device, dev_info);
- if (UAM_ERROR_NONE != _uam_core_add_device(account, &device)) {
+ ret = _uam_core_add_device(account, &device);
+ if (UAM_ERROR_NONE != ret)
UAM_ERR("_uam_core_remove_user() failed");
- return UAP_STATUS_FAIL;
- }
FUNC_EXIT;
- return UAP_STATUS_SUCCESS;
+ return ret;
}
static int remove_device(const char *device_id, int type)
FUNC_EXIT;
}
+static int __get_uas_error_code(int error)
+{
+ switch (error) {
+ case UAS_STATUS_SUCCESS: /* 0x00 */
+ return UAM_ERROR_NONE;
+ case UAS_STATUS_FAIL: /* 0x01 */
+ return UAM_ERROR_INTERNAL;
+ case UAS_STATUS_NOT_READY: /* 0x02 */
+ return UAM_ERROR_NOT_INITIALIZED;
+ case UAS_STATUS_NOMEM: /* 0x03 */
+ return UAM_ERROR_OUT_OF_MEMORY;
+ case UAS_STATUS_BUSY: /* 0x04 */
+ return UAM_ERROR_RESOURCE_BUSY;
+ case UAS_STATUS_ALREADY_DONE: /* 0x05 */
+ return UAM_ERROR_ALREADY_DONE;
+ case UAS_STATUS_UNSUPPORTED: /* 0x06 */
+ return UAM_ERROR_NOT_SUPPORTED;
+ default:
+ return UAM_ERROR_INTERNAL;
+ }
+}
+
static uas_device_info_t *__get_uas_device_list(int id, GSList *devices, int *num_devices)
{
FUNC_ENTRY;
int _uam_pm_register_device(int user_id, const uam_device_info_s *dev)
{
FUNC_ENTRY;
+
int id;
+ int ret = UAM_ERROR_NONE;
uam_sensor_plugin_info_t *plugin;
uas_device_info_t *device = NULL;
retv_if(NULL == device, UAM_ERROR_INTERNAL);
device->user_id = user_id;
- if (UAS_STATUS_SUCCESS != plugin->api->add_device(device)) {
+
+ ret = plugin->api->add_device(device);
+ if (UAS_STATUS_SUCCESS != ret) {
UAM_ERR("plugin->add_device() failed");
- return UAM_ERROR_INTERNAL;
}
+
_pm_util_uas_device_info_free(device);
FUNC_EXIT;
- return UAM_ERROR_NONE;
+ return __get_uas_error_code(ret);
}
int _uam_pm_unregister_device(int user_id, const uam_device_info_s *dev)
"duid TEXT, " \
"device_icon TEXT, " \
"FOREIGN KEY(user_id) REFERENCES userdata(user_id), " \
- "UNIQUE (device_id, tech_type, address) " \
+ "UNIQUE (device_id, tech_type) " \
"); "
#define CREATE_SERVICES_TABLE "CREATE TABLE IF NOT EXISTS services ( " \