+static inline int _bind_local_info(desktop_info_s* info, sqlite3_stmt * stmt)
+{
+ int ret = 0;
+ unsigned long i = 0;
+ struct name_item *item;
+ GSList* localname;
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+ localname = info->localname;
+ while (localname) {
+ item = (struct name_item *) localname->data;
+ if (item && item->locale && item->name) {
+ // Bind values for a triplet : package, locale, name
+ retv_if(db_bind_text(stmt, i+1, info->package) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+ retv_if(db_bind_text(stmt, i+2, item->locale) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+ retv_if(db_bind_text(stmt, i+3, item->name) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+ i += 3;
+ }
+ localname = g_slist_next(localname);
+ }
+ return AIL_ERROR_OK;
+}
+
+
+static inline int _len_local_info(desktop_info_s* info)
+{
+ int len = 0;
+ struct name_item *item;
+ GSList* localname;
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+ if(info->localname) {
+ localname = info->localname;
+ while (localname) {
+ item = (struct name_item *) localname->data;
+ if (item && item->locale && item->name)
+ len ++;
+ localname = g_slist_next(localname);
+ }
+ }
+ return len;
+}
+
+
+static inline int _insert_local_info(desktop_info_s* info, uid_t uid)
+{
+ int len_query = SQL_INSERT_LOCALNAME_STR_LEN;
+ int nb_locale_args;
+ char *query;
+ int ret = AIL_ERROR_OK;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
+
+ nb_locale_args = _len_local_info(info);
+
+ retv_if(!nb_locale_args, AIL_ERROR_INVALID_PARAMETER);
+
+ len_query += SQL_LOCALNAME_TRIPLET_STR_LEN*nb_locale_args +1;
+
+ query = (char *) malloc(len_query);
+ retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
+ stpncpy(query, SQL_INSERT_LOCALNAME_INIT_STR, len_query);
+ for (i = 0; i < nb_locale_args - 1; i++)
+ strcat(query, SQL_LOCALNAME_TRIPLET_STR);
+
+ do {
+ if(uid != GLOBAL_USER)
+ ret = db_prepare_rw(query, &stmt);
+ else
+ ret = db_prepare_globalrw(query, &stmt);
+ if (ret < 0) break;