Blender V5.3
preferences.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#include <cstring>
12
13#include "AS_asset_library.hh"
15#include "AS_remote_library.hh"
16
17#include "BLI_fileops.hh"
18#include "BLI_listbase.hh"
19#include "BLI_path_utils.hh"
20#include "BLI_string.hh"
21#include "BLI_string_utf8.hh"
22#include "BLI_string_utils.hh"
23
24#include "BKE_appdir.hh"
25#include "BKE_asset.hh"
26#include "BKE_blender_version.h"
27#include "BKE_preferences.h"
28
29#include "BLI_utildefines.hh"
30
31#include "BLT_translation.hh"
32
33#include "BLO_read_write.hh"
34
35#include "DNA_userdef_types.h"
36
37#include "RNA_define.hh"
38#include "RNA_enum_types.hh"
39
40namespace blender {
41
42#define U BLI_STATIC_ASSERT(false, "Global 'U' not allowed, only use arguments passed in!")
43
44/* -------------------------------------------------------------------- */
47
48namespace bke::preferences {
49
50bool exists()
51{
52 const std::optional<std::string> cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, nullptr);
53 if (!cfgdir.has_value()) {
54 return false;
55 }
56
57 char userpref[FILE_MAX];
58 BLI_path_join(userpref, sizeof(userpref), cfgdir->c_str(), BLENDER_USERPREF_FILE);
59 return BLI_exists(userpref);
60}
61
62} // namespace bke::preferences
63
65
66/* -------------------------------------------------------------------- */
69
71 const char *name,
72 const char *dirpath)
73{
74 bUserAssetLibrary *library = MEM_new<bUserAssetLibrary>(__func__);
75
78 library->import_method = ASSET_IMPORT_APPEND_REUSE;
79 }
80 if (name) {
82 }
83 if (dirpath) {
84 STRNCPY(library->resolved_dirpath, AS_asset_library_resolve_path(dirpath).c_str());
85 STRNCPY(library->dirpath, dirpath);
86 }
87
88 return library;
89}
90
92 const char *name,
93 const char *dirpath,
94 std::optional<UUID> uuid)
95{
98 library->uuid = uuid.value_or(BLI_uuid_generate_random());
99 return library;
100}
101
103{
104 MEM_delete(library->auth_token);
105 MEM_delete(library->invalid_uuid);
107}
108
111 const char *name)
112{
113 STRNCPY_UTF8(library->name, name);
115 library,
116 name,
117 '.',
119 sizeof(library->name));
120}
121
123{
124 STRNCPY(library->resolved_dirpath, AS_asset_library_resolve_path(path).c_str());
125 STRNCPY(library->dirpath, path);
126 if (BLI_is_file(library->resolved_dirpath)) {
128 BLI_path_parent_dir(library->resolved_dirpath);
129 }
130}
131
136
138 const char *name)
139{
140 return static_cast<bUserAssetLibrary *>(
142}
143
145 const char *path)
146{
147 for (bUserAssetLibrary &asset_lib_pref : userdef->asset_libraries) {
148 if (asset_lib_pref.resolved_dirpath[0] &&
149 BLI_path_contains(asset_lib_pref.resolved_dirpath, path))
150 {
151 return &asset_lib_pref;
152 }
153 }
154 return nullptr;
155}
156
159{
160 return BLI_findindex(&userdef->asset_libraries, library);
161}
162
165{
166 if (library->flag & ASSET_LIBRARY_DISABLED) {
167 return false;
168 }
169 if (library->extension_id[0]) {
171 library);
172 /* The libraries of a removed repository are removed too, any that remain are unusable. */
173 if (repo == nullptr) {
174 return false;
175 }
177 return false;
178 }
179 }
180 return true;
181}
182
185 const bool check_directory_exists)
186{
187 /* Check disabled libraries. */
189 return false;
190 }
191
192 /* Check remote libraries. */
193 const bool is_remote_library = library->flag & ASSET_LIBRARY_USE_REMOTE_URL;
194 const bool skip_remote_libraries = !USER_EXPERIMENTAL_TEST(userdef, use_remote_asset_libraries);
195 if (is_remote_library && skip_remote_libraries) {
196 return false;
197 }
198 if (is_remote_library && !library->remote_url[0]) {
199 return false;
200 }
201
202 /* Note that there's no check if the path exists on disk here. If an invalid library path is
203 * used, the Asset Browser can give a nice hint on what's wrong, so include such items in enums
204 * the user can choose from. */
205 if (!library->dirpath[0]) {
206 return false;
207 }
208 if (check_directory_exists && !BLI_is_dir(library->resolved_dirpath)) {
209 return false;
210 }
211
212 return true;
213}
214
216{
217 char documents_path[FILE_MAXDIR];
218
219 /* No home or documents path found, not much we can do. */
220 if (!BKE_appdir_folder_documents(documents_path) || !documents_path[0]) {
221 return;
222 }
223
226
227 /* Add new "Default" library under '[doc_path]/Blender/Assets'. */
229 library->dirpath, sizeof(library->dirpath), documents_path, N_("Blender"), N_("Assets"));
230 STRNCPY(library->resolved_dirpath, AS_asset_library_resolve_path(library->dirpath).c_str());
231}
232
234{
235 if (library->auth_token) {
236 BLO_read_string(reader, &library->auth_token);
237 }
238 if (library->invalid_uuid) {
239 BLO_read_string(reader, &library->invalid_uuid);
240 }
241 /* Ensure that the resolved path dir is up to date. */
242 STRNCPY(library->resolved_dirpath, AS_asset_library_resolve_path(library->dirpath).c_str());
243}
244
247{
248 if (library->auth_token) {
249 writer->write_string(library->auth_token);
250 }
251 if (library->invalid_uuid) {
252 writer->write_string(library->invalid_uuid);
253 }
254}
255
257 const char *name,
258 const char *remote_url,
259 const char *auth_token)
260{
261 bUserAssetLibrary *library = MEM_new<bUserAssetLibrary>(__func__);
262
265
266 if (name) {
268 }
269
271
272 if (auth_token && auth_token[0]) {
275 }
276
277 return library;
278}
279
281 const char *name,
282 const char *remote_url,
283 const char *auth_token)
284{
286 userdef, name, remote_url, auth_token);
288 return library;
289}
290
301
303 const UserDef *userdef, const bUserAssetLibrary *library)
304{
305 /* The repository module is the part before the first `.`, modules never contain one. */
306 char module[sizeof(bUserAssetLibrary::extension_id)];
307 STRNCPY(module, library->extension_id);
308 char *sep = strchr(module, '.');
309 if (sep == nullptr) {
310 return nullptr;
311 }
312 *sep = '\0';
313 return BKE_preferences_extension_repo_find_by_module(userdef, module);
314}
315
321static void url_ensure_trailing_slash(char *str, const size_t str_maxncpy)
322{
323 const size_t len = BLI_strnlen(str, str_maxncpy);
324 BLI_assert_msg(str[len] == '\0', "String should be null-terminated");
325
326 if (len > 0 && str[len - 1] != '/' && len + 1 < str_maxncpy) {
327 str[len] = '/';
328 str[len + 1] = '\0';
329 }
330}
331
333 const StringRef remote_url)
334{
335 /* Always trim white-space off of URLs. */
336 remote_url.trim().copy_bytes_truncated(library->remote_url);
337
338 const bool ends_in_top_meta_file = asset_system::remote_library_url_ends_with_top_meta_file_name(
339 library->remote_url);
340
341 if (!ends_in_top_meta_file) {
342 url_ensure_trailing_slash(library->remote_url, sizeof(library->remote_url));
343 }
344
345 /* Update location cache path. */
346 const std::string library_dirpath =
348 /* Special (unusual) case: When the URL path matches the online essentials URL, use the
349 * online essentials cache directory path. Otherwise the downloader deduplicates the
350 * requests, and only downloads file to one of the directories. */
353 STRNCPY(library->dirpath, library_dirpath.c_str());
354 STRNCPY(library->resolved_dirpath, AS_asset_library_resolve_path(library->dirpath).c_str());
355}
356
358 const StringRef auth_token)
359{
360 const StringRef auth_token_trimmed = StringRef{auth_token}.trim();
361 library->auth_token = BLI_strdupn(auth_token_trimmed.data(), auth_token_trimmed.size());
362}
363
365
366/* -------------------------------------------------------------------- */
369
373static size_t strncpy_py_module(char *dst, const char *src, const size_t dst_maxncpy)
374{
375 const size_t dst_len_max = dst_maxncpy - 1;
376 dst[0] = '\0';
377 size_t i_src = 0, i_dst = 0;
378 while (src[i_src] && (i_dst < dst_len_max)) {
379 const char c = src[i_src++];
380 const bool is_alpha = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
381 /* The first character must be `[a-zA-Z]`. */
382 if (i_dst == 0 && !is_alpha) {
383 continue;
384 }
385 const bool is_num = (is_alpha == false) && ((c >= '0' && c <= '9') || c == '_');
386 if (!(is_alpha || is_num)) {
387 continue;
388 }
389 dst[i_dst++] = c;
390 }
391 dst[i_dst] = '\0';
392 return i_dst;
393}
394
396 const char *name,
397 const char *module,
398 const char *custom_dirpath)
399{
400 bUserExtensionRepo *repo = MEM_new<bUserExtensionRepo>(__func__);
401 BLI_addtail(&userdef->extension_repos, repo);
402
403 /* Set the unique ID-name. */
404 BKE_preferences_extension_repo_name_set(userdef, repo, name);
405
406 /* Set the unique module-name. */
407 BKE_preferences_extension_repo_module_set(userdef, repo, module);
408
409 /* Set the directory. */
410 STRNCPY(repo->custom_dirpath, custom_dirpath);
413
414 /* While not a strict rule, ignored paths that already exist, *
415 * pointing to the same path is going to logical problems with package-management. */
416 for (const bUserExtensionRepo &repo_iter : userdef->extension_repos) {
417 if (repo == &repo_iter) {
418 continue;
419 }
420 if (BLI_path_cmp(repo->custom_dirpath, repo_iter.custom_dirpath) == 0) {
421 repo->custom_dirpath[0] = '\0';
422 break;
423 }
424 }
425
426 return repo;
427}
428
430{
431 if (repo->access_token) {
432 MEM_delete(repo->access_token);
433 }
434 BLI_freelinkN(&userdef->extension_repos, repo);
435}
436
438{
440 userdef, "extensions.blender.org", "blender_org", "");
441 /* The trailing slash on this URL is important, without it a redirect is used. */
442 STRNCPY(repo->remote_url, "https://extensions.blender.org/api/v1/extensions/");
443 /* Disable `blender.org` by default, the initial "Online Preferences" section gives
444 * the option to enable this. */
446 return repo;
447}
448
450{
452 userdef, "User Default", "user_default", "");
453 return repo;
454}
455
462
470
472 bUserExtensionRepo *repo,
473 const char *name)
474{
475 if (*name == '\0') {
476 name = "User Repository";
477 }
478 STRNCPY_UTF8(repo->name, name);
479
481 repo,
482 name,
483 '.',
485 sizeof(repo->name));
486}
487
489 bUserExtensionRepo *repo,
490 const char *module)
491{
492 if (strncpy_py_module(repo->module, module, sizeof(repo->module)) == 0) {
493 STRNCPY(repo->module, "repository");
494 }
495
497 repo,
498 module,
499 '_',
501 sizeof(repo->module));
502}
503
505{
506 /* NOTE: this should only ever return false in the case of corrupt file/memory
507 * and can be considered an exceptional situation. */
508 char module_test[sizeof(bUserExtensionRepo::module)];
509 const size_t module_len = strncpy_py_module(module_test, repo->module, sizeof(repo->module));
510 if (module_len == 0) {
511 return false;
512 }
513 if (module_len != STRNLEN(repo->module)) {
514 return false;
515 }
516 return true;
517}
518
520{
521 STRNCPY(repo->custom_dirpath, path);
522}
523
525 char *dirpath,
526 const int dirpath_maxncpy)
527{
529 return BLI_strncpy_rlen(dirpath, repo->custom_dirpath, dirpath_maxncpy);
530 }
531
532 std::optional<std::string> path = std::nullopt;
533
534 uint8_t source = repo->source;
537 }
538
539 switch (source) {
542 break;
543 }
544 default: { /* #USER_EXTENSION_REPO_SOURCE_USER. */
546 break;
547 }
548 }
549
550 /* Highly unlikely to fail as the directory doesn't have to exist. */
551 if (!path) {
552 dirpath[0] = '\0';
553 return 0;
554 }
555 return BLI_path_join(dirpath, dirpath_maxncpy, path.value().c_str(), repo->module);
556}
557
559 char *dirpath,
560 const int dirpath_maxncpy)
561{
562 if (std::optional<std::string> path = BKE_appdir_folder_id_user_notest(BLENDER_USER_EXTENSIONS,
563 nullptr))
564 {
565 return BLI_path_join(dirpath, dirpath_maxncpy, path.value().c_str(), ".user", repo->module);
566 }
567 return 0;
568}
569
574
576 const char *module)
577{
578 return static_cast<bUserExtensionRepo *>(
579 BLI_findstring(&userdef->extension_repos, module, offsetof(bUserExtensionRepo, module)));
580}
581
582static bool url_char_is_delimiter(const char ch)
583{
584 /* Punctuation (space to comma). */
585 if (ch >= 32 && ch <= 44) {
586 return true;
587 }
588 /* Other characters (colon to at-sign). */
589 if (ch >= 58 && ch <= 64) {
590 return true;
591 }
592 if (ELEM(ch, '/', '\\')) {
593 return true;
594 }
595 return false;
596}
597
599 const UserDef *userdef, const char *remote_url_full, const bool only_enabled)
600{
601 const int path_full_len = strlen(remote_url_full);
602 const int path_full_offset = BKE_preferences_remote_scheme_end(remote_url_full);
603
604 for (bUserExtensionRepo &repo : userdef->extension_repos) {
605 if (only_enabled && (repo.flag & USER_EXTENSION_REPO_FLAG_DISABLED)) {
606 continue;
607 }
608
609 /* Has a valid remote path to check. */
611 continue;
612 }
613 if (repo.remote_url[0] == '\0') {
614 continue;
615 }
616
617 /* Set path variables which may be offset by the "scheme". */
618 const char *path_repo = repo.remote_url;
619 const char *path_test = remote_url_full;
620 int path_test_len = path_full_len;
621
622 /* Allow paths beginning with both `http` & `https` to be considered equivalent.
623 * This is done by skipping the "scheme" prefix both have a scheme. */
624 if (path_full_offset) {
625 const int path_repo_offset = BKE_preferences_remote_scheme_end(path_repo);
626 if (path_repo_offset) {
627 path_repo += path_repo_offset;
628 path_test += path_full_offset;
629 path_test_len -= path_full_offset;
630 }
631 }
632
633 /* The length of the path without trailing slashes. */
634 int path_repo_len = strlen(path_repo);
635 while (path_repo_len && ELEM(path_repo[path_repo_len - 1], '/', '\\')) {
636 path_repo_len--;
637 }
638
639 if (path_test_len <= path_repo_len) {
640 continue;
641 }
642 if (memcmp(path_repo, path_test, path_repo_len) != 0) {
643 continue;
644 }
645
646 /* A delimiter must follow to ensure `path_test` doesn't reference a longer host-name.
647 * Will typically be a `/` or a `:`. */
648 if (!url_char_is_delimiter(path_test[path_repo_len])) {
649 continue;
650 }
651 return &repo;
652 }
653 return nullptr;
654}
655
657 const bUserExtensionRepo *repo)
658{
659 return BLI_findindex(&userdef->extension_repos, repo);
660}
661
663{
664 if (repo->access_token) {
665 BLO_read_string(reader, &repo->access_token);
666 }
667}
668
670{
671 if (repo->access_token) {
672 writer->write_string(repo->access_token);
673 }
674}
675
677
678/* -------------------------------------------------------------------- */
681
683{
684 /* Technically the "://" are not part of the scheme, so subtract 3 from the return value. */
685 const char *scheme_check[] = {
686 "http://",
687 "https://",
688 "file://",
689 };
690 for (int i = 0; i < ARRAY_SIZE(scheme_check); i++) {
691 const char *scheme = scheme_check[i];
692 int scheme_len = strlen(scheme);
693 if (strncmp(url, scheme, scheme_len) == 0) {
694 return scheme_len - 3;
695 }
696 }
697 return 0;
698}
699
700void BKE_preferences_remote_to_name(const char *remote_url, char name[MAX_NAME])
701{
702#ifdef _WIN32
703 const bool is_win32 = true;
704#else
705 const bool is_win32 = false;
706#endif
707 const bool is_file = STRPREFIX(remote_url, "file://");
708 name[0] = '\0';
709 if (int offset = BKE_preferences_remote_scheme_end(remote_url)) {
710 /* Skip the `://`. */
711 remote_url += (offset + 3);
712
713 if (is_file) {
714 if (is_win32) {
715 /* Skip the slash prefix for: `/C:/`,
716 * not *required* but seems like a bug if it's not done. */
717 if (remote_url[0] == '/' && isalpha(remote_url[1]) && (remote_url[2] == ':')) {
718 remote_url += 1;
719 }
720 }
721 }
722 else {
723 /* Skip the `www` as it's not useful information. */
724 if (BLI_str_startswith(remote_url, "www.")) {
725 remote_url += 4;
726 }
727 }
728 }
729 if (remote_url[0] == '\0') [[unlikely]] {
730 return;
731 }
732
733 const char *c = remote_url;
734 if (is_file) {
735 /* TODO: decode the URL, see: #GHOST_URL_decode which is not a public function. */
736
737 /* Don't use domain name only logic for file paths as this causes
738 * `file:///path/to/repo/index.json` -> `/path`
739 * In this case `/path/to/repo` is preferred. */
740 c = BLI_path_basename(remote_url);
741 /* Remove trailing slash. */
742 while ((remote_url < c) && url_char_is_delimiter(*(c - 1))) {
743 c--;
744 }
745 }
746 else {
747 /* Skip any delimiters (likely forward slashes for `file:///` on UNIX).
748 * Although the `file://` case is handled already. So this is quite unlikely.
749 * Skip them anyway because failing to do so may cause the domain to be an empty string. */
750 while (*c && url_char_is_delimiter(*c)) {
751 c++;
752 }
753 /* Skip the domain name. */
754 while (*c && !url_char_is_delimiter(*c)) {
755 c++;
756 }
757 }
758
759 BLI_strncpy_utf8(name, remote_url, std::min(size_t(c - remote_url) + 1, size_t(MAX_NAME)));
760
761 if (is_win32) {
762 if (is_file) {
764 }
765 }
766}
767
769
770/* -------------------------------------------------------------------- */
773
775 const char *shelf_idname)
776{
777 bUserAssetShelfSettings *settings = MEM_new<bUserAssetShelfSettings>(__func__);
778 BLI_addtail(&userdef->asset_shelves_settings, settings);
779 STRNCPY(settings->shelf_idname, shelf_idname);
780 BLI_assert(settings->enabled_catalog_paths.is_empty());
781 return settings;
782}
783
785 const char *shelf_idname)
786{
788 shelf_idname))
789 {
790 return settings;
791 }
792 return asset_shelf_settings_new(userdef, shelf_idname);
793}
794
796 const char *shelf_idname)
797{
798 return static_cast<bUserAssetShelfSettings *>(
800 shelf_idname,
801 offsetof(bUserAssetShelfSettings, shelf_idname)));
802}
803
805 const char *shelf_idname,
806 const char *catalog_path)
807{
809 shelf_idname);
810 if (!settings) {
811 return false;
812 }
813 return BKE_asset_catalog_path_list_has_path(settings->enabled_catalog_paths, catalog_path);
814}
815
817 const char *shelf_idname,
818 const char *catalog_path)
819{
821 userdef, shelf_idname, catalog_path))
822 {
823 return false;
824 }
825
826 bUserAssetShelfSettings *settings = asset_shelf_settings_ensure(userdef, shelf_idname);
828 return true;
829}
830
832 const char *shelf_idname,
833 const char *catalog_path)
834{
836 shelf_idname);
837 if (!settings) {
838 return false;
839 }
840
842}
843
845
847{
848
849 const bool use_developer_ui = (userdef->flag & USER_DEVELOPER_UI) != 0;
850 const bool is_alpha = BKE_blender_version_is_alpha();
851
852 if (use_developer_ui && is_alpha) {
853 *r_free = false;
855 }
856
857 EnumPropertyItem *items = nullptr;
858 int totitem = 0;
859
860 for (const EnumPropertyItem *it = rna_enum_preference_section_items; it->identifier != nullptr;
861 it++)
862 {
863 if (it->value == USER_SECTION_EXPERIMENTAL) {
864 if (is_alpha == false) {
865 continue;
866 }
867 }
868 else if (it->value == USER_SECTION_DEVELOPER_TOOLS) {
869 if (use_developer_ui == false) {
870 continue;
871 }
872 }
873
874 RNA_enum_item_add(&items, &totitem, it);
875 }
876
877 RNA_enum_item_end(&items, &totitem);
878
879 *r_free = true;
880 return items;
881}
882
883} // namespace blender
#define BLENDER_USERPREF_FILE
#define BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME
File and directory operations.
#define FILE_MAX
#define BLI_path_join(...)
#define FILE_MAXDIR
#define BLI_path_cmp
#define STRNLEN(str)
#define STRNCPY_UTF8(dst, src)
#define DATA_(msgid)
#define MAX_NAME
Definition DNA_defs.h:63
#define USER_EXPERIMENTAL_TEST(userdef, member)
#define STRPREFIX(a, b)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
constexpr StringRef trim() const
constexpr int64_t size() const
void copy_bytes_truncated(char *dst, int64_t dst_size) const
Definition string_ref.cc:47
constexpr const char * data() const
#define offsetof(t, d)
#define str(s)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
StringRefNull online_essentials_cache_directory_path()
bool is_online_essentials_url(StringRef url)
bool remote_library_url_ends_with_top_meta_file_name(const StringRef url)
std::string remote_library_cache_directory_path_from_url(StringRef remote_url)
BMesh Iterators.
bUserExtensionRepo * BKE_preferences_extension_repo_add_default_system(UserDef *userdef)
bool BKE_preferences_extension_repo_module_is_valid(const bUserExtensionRepo *repo)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
size_t BKE_preferences_extension_repo_user_dirpath_get(const bUserExtensionRepo *repo, char *dirpath, const int dirpath_maxncpy)
char * STRNCPY(char(&dst)[N], const char *src)
void BKE_preferences_asset_library_default_add(struct UserDef *userdef) ATTR_NONNULL()
bUserExtensionRepo * BKE_preferences_extension_repo_find_by_remote_url_prefix(const UserDef *userdef, const char *remote_url_full, const bool only_enabled)
int BKE_preferences_asset_library_get_index(const struct UserDef *userdef, const struct bUserAssetLibrary *library) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BKE_preferences_extension_repo_custom_dirpath_set(bUserExtensionRepo *repo, const char *path)
bool BKE_asset_catalog_path_list_has_path(const ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
static bUserAssetShelfSettings * asset_shelf_settings_ensure(UserDef *userdef, const char *shelf_idname)
const EnumPropertyItem * BKE_preferences_active_section_itemf(const UserDef *userdef, bool *r_free)
@ ASSET_LIBRARY_USE_AUTH_TOKEN
@ ASSET_LIBRARY_PROJECT_DEFINED
@ ASSET_LIBRARY_DISABLED
@ ASSET_LIBRARY_USE_REMOTE_URL
void BKE_preferences_extension_repo_module_set(UserDef *userdef, bUserExtensionRepo *repo, const char *module)
int BKE_preferences_extension_repo_get_index(const UserDef *userdef, const bUserExtensionRepo *repo)
struct bUserAssetLibrary * BKE_preferences_asset_library_add(struct UserDef *userdef, const char *name, const char *dirpath) ATTR_NONNULL(1)
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
int BKE_preferences_remote_scheme_end(const char *url)
bUserExtensionRepo * BKE_preferences_extension_repo_add_default_user(UserDef *userdef)
struct bUserAssetLibrary * BKE_preferences_remote_asset_library_add(struct UserDef *userdef, const char *name, const char *remote_url, const char *auth_token) ATTR_NONNULL(1
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void BKE_preferences_asset_library_remove(struct UserDef *userdef, struct bUserAssetLibrary *library) ATTR_NONNULL()
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:615
bool BKE_blender_version_is_alpha()
Definition blender.cc:177
void BKE_preferences_extension_repo_name_set(UserDef *userdef, bUserExtensionRepo *repo, const char *name)
struct bUserAssetLibrary * BKE_preferences_asset_library_find_index(const struct UserDef *userdef, int index) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void BKE_preferences_extension_repo_read_data(struct BlendDataReader *reader, bUserExtensionRepo *repo)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool BKE_preferences_asset_shelf_settings_ensure_catalog_path_enabled(UserDef *userdef, const char *shelf_idname, const char *catalog_path)
bool BKE_preferences_asset_library_is_valid(const UserDef *userdef, const struct bUserAssetLibrary *library, const bool check_directory_exists) ATTR_NONNULL()
void BLI_path_slash_native(char *path) ATTR_NONNULL(1)
bUserExtensionRepo * BKE_preferences_extension_repo_find_by_module(const UserDef *userdef, const char *module)
void BKE_preferences_extension_repo_write_data(struct BlendWriter *writer, const bUserExtensionRepo *repo)
bUserAssetShelfSettings * BKE_preferences_asset_shelf_settings_get(const UserDef *userdef, const char *shelf_idname)
static bUserAssetShelfSettings * asset_shelf_settings_new(UserDef *userdef, const char *shelf_idname)
struct bUserAssetLibrary * BKE_preferences_project_asset_library_add(struct UserDef *userdef, const char *name, const char *dirpath, std::optional< UUID > uuid=std::nullopt) ATTR_NONNULL(1)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
void BLI_uniquename(const ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_maxncpy) ATTR_NONNULL(1
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
void BKE_preferences_remote_to_name(const char *remote_url, char name[64])
std::optional< std::string > BKE_appdir_folder_id(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:762
void BLI_path_slash_rstrip(char *path) ATTR_NONNULL(1)
@ USER_SECTION_EXPERIMENTAL
@ USER_SECTION_DEVELOPER_TOOLS
void BKE_preferences_asset_library_write_data(struct BlendWriter *writer, const struct bUserAssetLibrary *library)
std::string AS_asset_library_resolve_path(StringRef path)
@ ASSET_IMPORT_APPEND_REUSE
static size_t strncpy_py_module(char *dst, const char *src, const size_t dst_maxncpy)
bUserExtensionRepo * BKE_preferences_extension_repo_add_default_remote(UserDef *userdef)
struct bUserExtensionRepo * BKE_preferences_extension_asset_library_repo_get(const struct UserDef *userdef, const struct bUserAssetLibrary *library) ATTR_NONNULL()
@ USER_EXTENSION_REPO_SOURCE_SYSTEM
@ USER_EXTENSION_REPO_SOURCE_USER
bUserAssetLibraryOwner BKE_preferences_asset_library_owner_get(const struct bUserAssetLibrary *library) ATTR_NONNULL()
unsigned char uint8_t
Definition BKE_text.h:79
char char size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
struct bUserAssetLibrary bUserAssetLibrary * BKE_preferences_project_remote_asset_library_add(UserDef *userdef, const char *name, const char *remote_url, const char *auth_token) ATTR_NONNULL(1
void BKE_preferences_remote_asset_library_auth_token_set(bUserAssetLibrary *library, StringRef auth_token)
Update the remote URL authentication token.
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:277
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
struct bUserAssetLibrary * BKE_preferences_asset_library_find_by_name(const struct UserDef *userdef, const char *name) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BKE_appdir_folder_documents(char *dir) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:174
int BLI_path_normalize(char *path) ATTR_NONNULL(1)
bUserExtensionRepo * BKE_preferences_extension_repo_find_index(const UserDef *userdef, int index)
bool BKE_preferences_asset_shelf_settings_disable_catalog_path(UserDef *userdef, const char *shelf_idname, const char *catalog_path)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void BKE_preferences_extension_repo_remove(UserDef *userdef, bUserExtensionRepo *repo)
bUUID BLI_uuid_generate_random()
Definition uuid.cc:26
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:457
std::optional< std::string > BKE_appdir_folder_id_user_notest(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
Definition appdir.cc:771
void BKE_preferences_extension_repo_add_defaults_all(UserDef *userdef)
@ USER_EXTENSION_REPO_FLAG_DISABLED
@ USER_EXTENSION_REPO_FLAG_USE_REMOTE_URL
@ USER_EXTENSION_REPO_FLAG_SYNC_ON_STARTUP
@ USER_EXTENSION_REPO_FLAG_USE_CUSTOM_DIRECTORY
bool BKE_preferences_asset_library_is_available(const struct UserDef *userdef, const struct bUserAssetLibrary *library) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
bool BLI_path_parent_dir(char *path) ATTR_NONNULL(1)
const EnumPropertyItem rna_enum_preference_section_items[]
void BKE_preferences_asset_library_name_set(struct UserDef *userdef, struct bUserAssetLibrary *library, const char *name) ATTR_NONNULL()
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
void BKE_preferences_remote_asset_library_url_set(bUserAssetLibrary *library, StringRef remote_url)
Update the remote URL and the cache directory derived from the URL.
bool BKE_asset_catalog_path_list_remove_path(ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
bUserExtensionRepo * BKE_preferences_extension_repo_add(UserDef *userdef, const char *name, const char *module, const char *custom_dirpath)
int bool BLI_str_startswith(const char *__restrict str, const char *__restrict start) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
bool BLI_path_contains(const char *container_path, const char *containee_path) ATTR_NONNULL(1
void BKE_preferences_asset_library_path_set(struct bUserAssetLibrary *library, const char *path) ATTR_NONNULL()
bool BKE_preferences_asset_shelf_settings_is_catalog_path_enabled(const UserDef *userdef, const char *shelf_idname, const char *catalog_path)
@ BLENDER_SYSTEM_EXTENSIONS
@ BLENDER_USER_EXTENSIONS
@ BLENDER_USER_CONFIG
void BKE_asset_catalog_path_list_add_path(ListBaseT< AssetCatalogPathLink > &catalog_path_list, const char *catalog_path)
static void url_ensure_trailing_slash(char *str, const size_t str_maxncpy)
void BKE_preferences_asset_library_read_data(struct BlendDataReader *reader, struct bUserAssetLibrary *library)
bool BLI_is_file(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:469
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
Definition readfile.cc:6653
static bool url_char_is_delimiter(const char ch)
struct bUserAssetLibrary * BKE_preferences_asset_library_containing_path(const struct UserDef *userdef, const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
size_t BKE_preferences_extension_repo_dirpath_get(const bUserExtensionRepo *repo, char *dirpath, int dirpath_maxncpy)
void write_string(const char *data)
ListBaseT< bUserExtensionRepo > extension_repos
ListBaseT< bUserAssetLibrary > asset_libraries
eUserPref_Flag flag
ListBaseT< bUserAssetShelfSettings > asset_shelves_settings
UserDef_Experimental experimental
ListBaseT< AssetCatalogPathLink > enabled_catalog_paths
eUserExtensionRepo_Flag flag
eUserExtensionRepo_Source source
#define N_(msgid)