FUNC_EXIT;
}
+static char *__get_mac_addr(uam_db_tech_info_t *tech)
+{
+ FUNC_ENTRY;
+ GSList *l;
+
+ retv_if(NULL == tech, NULL);
+
+ for (l = tech->addresses; NULL != l; l = g_slist_next(l)) {
+ uam_db_address_info_t *addr = l->data;
+
+ if (!addr)
+ continue;
+
+ if (addr->addr_type == UAM_ADDR_TYPE_BT ||
+ addr->addr_type == UAM_ADDR_TYPE_BLE ||
+ addr->addr_type == UAM_ADDR_TYPE_WIFI ||
+ addr->addr_type == UAM_ADDR_TYPE_P2P)
+ return addr->address;
+ }
+
+ FUNC_EXIT;
+ return NULL;
+}
+
static void __remove_user_device(gpointer data)
{
FUNC_ENTRY;
retv_if(NULL == db_svc_list, NULL);
+ /*
+ * Iterate over the db_svc_list and add each service to the global
+ * service list "services" if its not already inserted. Also append this
+ * uam_db_service_info_t to svc_list.
+ */
for (l = db_svc_list; NULL != l; l = g_slist_next(l)) {
- /*
- * TODO: Iterate over the db_svc_list and add each service to the global
- * service list "services" if its not already inserted. Also append this
- * uam_db_service_info_t to svc_list.
- * */
+ db_service_info_t *db_svc = l->data;
+ uam_db_service_info_t *service;
+ GSList *l1;
+
+ if (!db_svc)
+ continue;
+
+ l1 = g_slist_find_custom(services,
+ db_svc->service_name, __compare_svc_name);
+ if (!l1) {
+ service = g_new0(uam_db_service_info_t, 1);
+ service->name = g_strdup(db_svc->service_name);
+ service->cycle = db_svc->cycle;
+ services = g_slist_append(services, service);
+ } else
+ service = l1->data;
+
+ svc_list = g_slist_append(svc_list, service);
}
FUNC_EXIT;
for (l1 = device->tech_list; NULL != l1; l1 = g_slist_next(l1)) {
uam_db_tech_info_t *tech = l1->data;
+ char *mac;
GSList *l2;
if (!tech)
__add_service_to_dev_tech_mapping(tech, service);
- /*
- * TODO: insert device service info to db
- * if (UAM_ERROR_NONE != _uam_db_insert_device_service_info(device->device_id,
- * tech->tech_type, ->mac, service->name, service->cycle))
- * UAM_WARN("Device service addition to persistent DB failed");
- */
+ mac = __get_mac_addr(tech);
+ /* Insert device service info to db */
+ if (UAM_ERROR_NONE != _uam_db_insert_device_service_info(device->device_id,
+ tech->tech_type, mac, service->name, service->cycle))
+ UAM_WARN("Device service addition to persistent DB failed");
}
}
for (l1 = device->tech_list; NULL != l1; l1 = g_slist_next(l1)) {
uam_db_tech_info_t *tech = l1->data;
+ char *mac;
GSList *l2;
if (!tech)
__remove_service_to_dev_tech_mapping(
tech, (uam_db_service_info_t *)l2->data);
- /*
- * TODO: Remove service-device from DB
- * if (UAM_ERROR_NONE != _uam_db_delete_device_service_info(
- * device->device_id, tech->tech_type, mac, svc_name))
- * UAM_WARN("Device service removal from persistent DB failed");
- */
+ mac = __get_mac_addr(tech);
+ /* Remove service-device from DB */
+ if (UAM_ERROR_NONE != _uam_db_delete_device_service_info(
+ device->device_id, tech->tech_type, mac, svc_name))
+ UAM_WARN("Device service removal from persistent DB failed");
}
}
{
FUNC_ENTRY;
GSList *l;
+ char *mac;
uam_db_tech_info_t *tech_info;
uam_db_service_info_t *service;
__add_service_to_dev_tech_mapping(tech_info, service);
- /*
- * TODO: insert device service info to db
- * if (UAM_ERROR_NONE != _uam_db_insert_device_service_info(device_id,
- * tech_type, mac, service->name, service->cycle))
- * UAM_WARN("Device service addition to persistent DB failed");
- */
+ mac = __get_mac_addr(tech_info);
+ /* Insert device service info to db */
+ if (UAM_ERROR_NONE != _uam_db_insert_device_service_info(device_id,
+ tech_type, mac, service->name, service->cycle))
+ UAM_WARN("Device service addition to persistent DB failed");
FUNC_EXIT;
return UAM_ERROR_NONE;
{
FUNC_ENTRY;
GSList *l;
+ char *mac;
uam_db_tech_info_t *tech_info;
retv_if(NULL == svc_name, UAM_ERROR_INVALID_PARAM);
__remove_service_to_dev_tech_mapping(tech_info, (uam_db_service_info_t *)l->data);
- /*
- * TODO: 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");
- */
+ 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");
FUNC_EXIT;
return UAM_ERROR_NONE;
else
service->remaining_time = new_cycle - elapsed_time;
- /*
- * TODO: Update service detection cycle in DB
- * if (UAM_ERROR_NONE != _uam_db_update_service_cycle(svc_name, new_cycle))
- * UAM_WARN("Service cycle updation to persistent DB failed");
- */
+ /* Update service detection cycle in DB */
+ if (UAM_ERROR_NONE != _uam_db_update_service_cycle(svc_name, new_cycle))
+ UAM_WARN("Service cycle updation to persistent DB failed");
FUNC_EXIT;
return UAM_ERROR_NONE;
}
user = l1->data;
-#if 0
- /* TODO: Fetch device services from DB */
+ /* Fetch device services from DB */
l1 = _uam_db_get_device_services(
db_info->dev_info.device_id,
db_info->dev_info.type,
db_info->dev_info.mac);
-#else
- l1 = NULL;
-#endif
+
svc_list = __convert_db_svc_list_to_uam_svc_list(l1);
__uam_core_add_dev_to_list(user, &(db_info->dev_info),
db_info->presence_state, db_info->timestamp, svc_list);
dev_info, UAM_PRESENCE_STATE_PRESENT, timestamp))
UAM_WARN("Device addition to persistent DB failed");
- /*
- * TODO: insert device service info to db
- * if (UAM_ERROR_NONE != _uam_db_insert_device_service_info(
- * dev_info->device_id, dev_info->type, dev_info->mac,
- * UAM_SERVICE_DEFAULT, UAM_DETECTION_CYCLE_DEFAULT))
- * UAM_WARN("Device service addition to persistent DB failed");
- */
+ /* Insert device service info to db */
+ if (UAM_ERROR_NONE != _uam_db_insert_device_service_info(
+ dev_info->device_id, dev_info->type, dev_info->mac,
+ UAM_SERVICE_DEFAULT, UAM_DETECTION_CYCLE_DEFAULT))
+ UAM_WARN("Device service addition to persistent DB failed");
/* Send device added event to application */
__send_device_event(UAM_EVENT_DEVICE_ADDED, dev_info);