|
|
@@ -377,12 +377,38 @@ void appModuleBrowserCreate() { |
|
|
|
} |
|
|
|
|
|
|
|
json_t *appModuleBrowserToJson() { |
|
|
|
// TODO |
|
|
|
return json_object(); |
|
|
|
json_t *rootJ = json_object(); |
|
|
|
|
|
|
|
json_t *favoritesJ = json_array(); |
|
|
|
for (Model *model : sFavoriteModels) { |
|
|
|
json_t *modelJ = json_object(); |
|
|
|
json_object_set_new(modelJ, "plugin", json_string(model->plugin->slug.c_str())); |
|
|
|
json_object_set_new(modelJ, "model", json_string(model->slug.c_str())); |
|
|
|
json_array_append_new(favoritesJ, modelJ); |
|
|
|
} |
|
|
|
json_object_set_new(rootJ, "favorites", favoritesJ); |
|
|
|
|
|
|
|
return rootJ; |
|
|
|
} |
|
|
|
|
|
|
|
void appModuleBrowserFromJson(json_t *root) { |
|
|
|
// TODO |
|
|
|
void appModuleBrowserFromJson(json_t *rootJ) { |
|
|
|
json_t *favoritesJ = json_object_get(rootJ, "favorites"); |
|
|
|
if (favoritesJ) { |
|
|
|
size_t i; |
|
|
|
json_t *favoriteJ; |
|
|
|
json_array_foreach(favoritesJ, i, favoriteJ) { |
|
|
|
json_t *pluginJ = json_object_get(favoriteJ, "plugin"); |
|
|
|
json_t *modelJ = json_object_get(favoriteJ, "model"); |
|
|
|
if (!pluginJ || !modelJ) |
|
|
|
continue; |
|
|
|
std::string pluginSlug = json_string_value(pluginJ); |
|
|
|
std::string modelSlug = json_string_value(modelJ); |
|
|
|
Model *model = pluginGetModel(pluginSlug, modelSlug); |
|
|
|
if (!model) |
|
|
|
continue; |
|
|
|
sFavoriteModels.insert(model); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|