Debian Codegraph @

src/core/profileiconcache.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/profileiconcache.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "profileiconcache.h"cxx . . $ `<file>/src/core/profileiconcache.h`/
5
6 #include "ifilecache.h"cxx . . $ `<file>/src/core/ifilecache.h`/
7 #include <spdlog/spdlog.h>
8 #include <utility>
9
10 ProfileIconCachecxx . . $ ProfileIconCache#::ProfileIconCachecxx . . $ ProfileIconCache#ProfileIconCache(4499baa0f79f933b).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IFileCachecxx . . $ IFileCache#> &&cache) noexcept
11 : cache_cxx . . $ ProfileIconCache#cache_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cache))
12 {
13 }
14
15 void ProfileIconCachecxx . . $ ProfileIconCache#::initcxx . . $ ProfileIconCache#init(49f6e7a06ebc5aa8).()
16 {
17 cache_cxx . . $ ProfileIconCache#cache_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initcxx . . $ IFileCache#init(49f6e7a06ebc5aa8).();
18 }
19
20 bool ProfileIconCachecxx . . $ ProfileIconCache#::tryOrCachecxx . . $ ProfileIconCache#tryOrCache(55a8732119d590fe).(IProfilecxx . . $ IProfile#::Infocxx . . $ IProfile#Info# &info,
21 stdcxx . . $ std/::vectorcxx . . $ std/vector#<char> const &fallbackIcon)
22 {
23 auto fileName = info.execxx . . $ IProfile#Info#exe. != IProfilecxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Infocxx . . $ IProfile#Info#::ManualIDcxx . . $ IProfile#Info#ManualID. ? infocxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)..execxx . . $ IProfile#Info#exe.
24 : info.execxx . . $ IProfile#Info#exe. +cxx . . $ std/operator+(2764d1739bf7913d). info.namecxx . . $ IProfile#Info#name.;
25 // try the cache
26 auto cacheURL = cache_cxx . . $ ProfileIconCache#cache_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).getcxx . . $ IFileCache#get(e718be3153167360).(fileName);
27 if (cacheURL.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) {
28 if (infocxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)..iconURLcxx . . $ IProfile#Info#iconURL. != *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cacheURL)
29 info.iconURLcxx . . $ IProfile#Info#iconURL. =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cacheURL;
30 return true;
31 }
32
33 // cache fallback icon
34 return cachecxx . . $ ProfileIconCache#cache(55a8732119d590fe).(info, fallbackIcon);
35 }
36
37 bool ProfileIconCachecxx . . $ ProfileIconCache#::cachecxx . . $ ProfileIconCache#cache(55a8732119d590fe).(IProfilecxx . . $ IProfile#::Infocxx . . $ IProfile#Info# &info,
38 stdcxx . . $ std/::vectorcxx . . $ std/vector#<char> const &iconData)
39 {
40 auto cacheURL = cacheIconFromDatacxx . . $ ProfileIconCache#cacheIconFromData(265168d99255d22a).(iconData, info);
41 if (cacheURL.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) {
42 info.iconURLcxx . . $ IProfile#Info#iconURL. =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cacheURL;
43 return true;
44 }
45
46 return false;
47 }
48
49 stdcxx . . $ std/::paircxx . . $ std/pair#<bool, bool> ProfileIconCachecxx . . $ ProfileIconCache#::syncCachecxx . . $ ProfileIconCache#syncCache(2154c7156f3f0c8c).(IProfilecxx . . $ IProfile#::Infocxx . . $ IProfile#Info# &info)
50 {
51 auto fileName = info.execxx . . $ IProfile#Info#exe. != IProfilecxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Infocxx . . $ IProfile#Info#::ManualIDcxx . . $ IProfile#Info#ManualID. ? infocxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)..execxx . . $ IProfile#Info#exe.
52 : info.execxx . . $ IProfile#Info#exe. +cxx . . $ std/operator+(2764d1739bf7913d). info.namecxx . . $ IProfile#Info#name.;
53 auto cacheURL = cache_cxx . . $ ProfileIconCache#cache_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).addcxx . . $ IFileCache#add(efab1f07c9a586fc).(infocxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)..iconURLcxx . . $ IProfile#Info#iconURL., fileName);
54 if (cacheURL.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) {
55 auto updateURL = infocxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)..iconURLcxx . . $ IProfile#Info#iconURL. != *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cacheURL;
56 if (updateURL)
57 info.iconURLcxx . . $ IProfile#Info#iconURL. =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cacheURL;
58
59 return {cxx . . $ std/pair#pair(62e1774a2dc03c82).true, updateURL};
60 }
61
62 SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("Failed to cache icon for {}", fileName.data());
63 return {cxx . . $ std/pair#pair(62e1774a2dc03c82).false, false};
64 }
65
66 void ProfileIconCachecxx . . $ ProfileIconCache#::cleancxx . . $ ProfileIconCache#clean(874cae2a8ac0280d).(IProfilecxx . . $ IProfile#::Infocxx . . $ IProfile#Info# &info)
67 {
68 auto fileName = info.execxx . . $ IProfile#Info#exe. != IProfilecxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Infocxx . . $ IProfile#Info#::ManualIDcxx . . $ IProfile#Info#ManualID. ? infocxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)..execxx . . $ IProfile#Info#exe.
69 : info.execxx . . $ IProfile#Info#exe. +cxx . . $ std/operator+(2764d1739bf7913d). info.namecxx . . $ IProfile#Info#name.;
70 cache_cxx . . $ ProfileIconCache#cache_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).removecxx . . $ IFileCache#remove(9c546c94e5fcce4e).(fileName);
71 }
72
73 stdcxx . . $ std/::optionalcxx . . $ std/optional#<stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path#>
74 ProfileIconCachecxx . . $ ProfileIconCache#::cacheIconFromDatacxx . . $ ProfileIconCache#cacheIconFromData(265168d99255d22a).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<char> const &iconData,
75 IProfilecxx . . $ IProfile#::Infocxx . . $ IProfile#Info# const &info) const
76 {
77 auto fileName = info.execxx . . $ IProfile#Info#exe. != IProfilecxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Infocxx . . $ IProfile#Info#::ManualIDcxx . . $ IProfile#Info#ManualID. ? infocxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5)..execxx . . $ IProfile#Info#exe.
78 : info.execxx . . $ IProfile#Info#exe. +cxx . . $ std/operator+(2764d1739bf7913d). info.namecxx . . $ IProfile#Info#name.;
79 auto cacheURL = cache_cxx . . $ ProfileIconCache#cache_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).addcxx . . $ IFileCache#add(d83eed0e64cf1041).(iconData, fileName);
80 if (cacheURL.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).())
81 return cacheURL;
82
83 SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("Failed to cache icon for {}", fileName.data());
84 return {cxx . . $ std/optional#optional(ced63f7c635d850d).};
85 }