GSList *addresses;
int presence_state;
long long int timestamp;
- const struct uam_db_device_info *device;
+ struct uam_db_device_info *device;
} uam_db_tech_info_t;
typedef struct uam_db_device_info {
char *device_id;
GSList *tech_list;
unsigned int supported_techs;
- const struct uam_db_user_info *user;
+ int presence_state;
+ long long int timestamp;
+ struct uam_db_user_info *user;
} uam_db_device_info_t;
typedef struct uam_db_user_info {
*
*/
+#include <time.h>
+
#include "ua-api.h"
#include "ua-internal.h"
#include "ua-manager-common.h"
#include "ua-plugin-manager.h"
+#define VD_REQ
+
+#ifdef VD_REQ
+#define UAM_MAX_DEVICES 6 /* VD Requirement */
+#endif
+
#define UAM_MAX_USERS 255
#define USER_EMAIL_DEFAULT "default@default.com"
#define USER_NAME_DEFAULT "default"
UAM_ERROR_ALREADY_REGISTERED);
}
+#ifdef VD_REQ
+ if (UAM_MAX_DEVICES <= g_slist_length(devices)) {
+ uam_db_user_info_t *user1;
+ uam_db_device_info_t *dev = NULL;
+ long long int timestamp = time(NULL);
+
+ /* Remove least recently used device */
+ for (l = devices; NULL != l; l = g_slist_next(l)) {
+ uam_db_device_info_t *device = l->data;
+
+ if (!device)
+ continue;
+
+ if (timestamp > device->timestamp) {
+ timestamp = device->timestamp;
+ dev = device;
+ }
+ }
+
+ /* Remove device from user's device list */
+ user1 = dev->user;
+ user1->devices = g_slist_remove(user1->devices, dev);
+
+ /* Remove device from list */
+ __remove_user_device(dev);
+
+ UAM_INFO("Total devices = %d", g_slist_length(devices));
+ }
+#endif
+
ret = _uam_pm_register_device(user->user_id, dev_info);
if (UAM_ERROR_NONE != ret) {
UAM_ERR("_uam_pm_register_device failed with %s",