Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/fmt/bookmarks.h

raw
1 /*
2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2020 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 14 окт. 2019 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_FMT_BOOKMARKS_H_
23 #define LSP_PLUG_IN_FMT_BOOKMARKS_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/lltl/parray.h>
27 #include <lsp-plug.in/common/status.h>
28 #include <lsp-plug.in/runtime/LSPString.h>
29 #include <lsp-plug.in/io/Path.h>
30 #include <lsp-plug.in/io/IInSequence.h>
31 #include <lsp-plug.in/io/IOutSequence.h>
32
33 #define GTK3_BOOKMARK_PATH ".config/gtk-3.0/bookmarks"
34 #define GTK2_BOOKMARK_PATH ".gtk-bookmarks"
35 #define QT5_BOOKMARK_PATH ".local/share/user-places.xbel"
36 #define LNK_BOOKMARK_PATH "Links"
37
38 namespace lsp
39 {
40 namespace bookmarks
41 {
42 enum bm_origin_t
43 {
44 BM_LSP = 1 << 0,
45 BM_GTK2 = 1 << 1,
46 BM_GTK3 = 1 << 2,
47 BM_QT5 = 1 << 3,
48 BM_LNK = 1 << 4,
49 };
50
51 typedef struct bookmark_t
52 {
53 LSPString path; // Path to the directory
54 LSPString name; // Bookmark name
55 size_t origin; // Bookmark origin: LSP, GTK3, QT
56 } bookmark_t;
57
58 /**
59 * Read GTK3 bookmarks
60 * @param dst list to store bookmarks
61 * @param path location of the file in UTF-8 encoding
62 * @param charset file encoding character set, NULL for default locale
63 * @return status of operation
64 */
65 status_t read_bookmarks_gtk3(lltl::parray<bookmark_t> *dst, const char *path, const char *charset=NULL);
66
67 /**
68 * Read GTK3 bookmarks
69 * @param dst list to store bookmarks
70 * @param path location of the file
71 * @param charset file encoding character set, NULL for default locale
72 * @return status of operation
73 */
74 status_t read_bookmarks_gtk3(lltl::parray<bookmark_t> *dst, const LSPString *path, const char *charset=NULL);
75
76 /**
77 * Read GTK3 bookmarks
78 * @param dst list to store bookmarks
79 * @param path location of the file
80 * @param charset file encoding character set, NULL for default locale
81 * @return status of operation
82 */
83 status_t read_bookmarks_gtk3(lltl::parray<bookmark_t> *dst, const io::Path *path, const char *charset=NULL);
84
85 /**
86 * Read GTK3 bookmarks
87 * @param dst list to store bookmarks
88 * @param in input character sequence
89 * @return status of operation
90 */
91 status_t read_bookmarks_gtk3(lltl::parray<bookmark_t> *dst, io::IInSequence *in);
92
93 /**
94 * Read GTK3 bookmarks
95 * @param dst list to store bookmarks
96 * @param path location of the file in UTF-8 encoding
97 * @param charset file encoding character set, NULL for default locale
98 * @return status of operation
99 */
100 status_t read_bookmarks_gtk2(lltl::parray<bookmark_t> *dst, const char *path, const char *charset=NULL);
101
102 /**
103 * Read GTK3 bookmarks
104 * @param dst list to store bookmarks
105 * @param path location of the file
106 * @param charset file encoding character set, NULL for default locale
107 * @return status of operation
108 */
109 status_t read_bookmarks_gtk2(lltl::parray<bookmark_t> *dst, const LSPString *path, const char *charset=NULL);
110
111 /**
112 * Read GTK3 bookmarks
113 * @param dst list to store bookmarks
114 * @param path location of the file
115 * @param charset file encoding character set, NULL for default locale
116 * @return status of operation
117 */
118 status_t read_bookmarks_gtk2(lltl::parray<bookmark_t> *dst, const io::Path *path, const char *charset=NULL);
119
120 /**
121 * Read GTK3 bookmarks
122 * @param dst list to store bookmarks
123 * @param in input character sequence
124 * @return status of operation
125 */
126 status_t read_bookmarks_gtk2(lltl::parray<bookmark_t> *dst, io::IInSequence *in);
127
128 /**
129 * Read QT5 bookmarks
130 * @param dst list to store bookmarks
131 * @param path location of the file in UTF-8 encoding
132 * @param charset file encoding character set, NULL for default locale
133 * @return status of operation
134 */
135 status_t read_bookmarks_qt5(lltl::parray<bookmark_t> *dst, const char *path, const char *charset=NULL);
136
137 /**
138 * Read QT5 bookmarks
139 * @param dst list to store bookmarks
140 * @param path location of the file
141 * @param charset file encoding character set, NULL for default locale
142 * @return status of operation
143 */
144 status_t read_bookmarks_qt5(lltl::parray<bookmark_t> *dst, const LSPString *path, const char *charset=NULL);
145
146 /**
147 * Read QT5 bookmarks
148 * @param dst list to store bookmarks
149 * @param path location of the file
150 * @param charset file encoding character set, NULL for default locale
151 * @return status of operation
152 */
153 status_t read_bookmarks_qt5(lltl::parray<bookmark_t> *dst, const io::Path *path, const char *charset=NULL);
154
155 /**
156 * Read QT5 bookmarks
157 * @param dst list to store bookmarks
158 * @param in input character sequence
159 * @return status of operation
160 */
161 status_t read_bookmarks_qt5(lltl::parray<bookmark_t> *dst, io::IInSequence *in);
162
163 /**
164 * Read Windows bookmarks from the specified folder
165 * @param dst destination array to store bookmarks
166 * @param path location of *.lnk files to read bookmarks
167 * @return status of operation
168 */
169 status_t read_bookmarks_lnk(lltl::parray<bookmark_t> *dst, const char *path);
170
171 /**
172 * Read Windows bookmarks from the specified folder
173 * @param dst destination array to store bookmarks
174 * @param path location of *.lnk files to read bookmarks
175 * @return status of operation
176 */
177 status_t read_bookmarks_lnk(lltl::parray<bookmark_t> *dst, const LSPString *path);
178
179 /**
180 * Read Windows bookmarks from the specified folder
181 * @param dst destination array to store bookmarks
182 * @param path location of *.lnk files to read bookmarks
183 * @return status of operation
184 */
185 status_t read_bookmarks_lnk(lltl::parray<bookmark_t> *dst, const io::Path *path);
186
187 /**
188 * Read LSP bookmarks in JSON5 format
189 * @param dst list to store bookmarks
190 * @param path location of the file in UTF-8 encoding
191 * @param charset file encoding character set, NULL for default locale
192 * @return status of operation
193 */
194 status_t read_bookmarks(lltl::parray<bookmark_t> *dst, const char *path, const char *charset=NULL);
195
196 /**
197 * Read LSP bookmarks in JSON5 format
198 * @param dst list to store bookmarks
199 * @param path location of the file
200 * @param charset file encoding character set, NULL for default locale
201 * @return status of operation
202 */
203 status_t read_bookmarks(lltl::parray<bookmark_t> *dst, const LSPString *path, const char *charset=NULL);
204
205 /**
206 * Read LSP bookmarks in JSON5 format
207 * @param dst list to store bookmarks
208 * @param path location of the file
209 * @param charset file encoding character set, NULL for default locale
210 * @return status of operation
211 */
212 status_t read_bookmarks(lltl::parray<bookmark_t> *dst, const io::Path *path, const char *charset=NULL);
213
214 /**
215 * Read LSP bookmarks in JSON5 format
216 * @param dst list to store bookmarks
217 * @param in input character sequence
218 * @return status of operation
219 */
220 status_t read_bookmarks(lltl::parray<bookmark_t> *dst, io::IInSequence *in);
221
222 /**
223 * Save LSP bookmarks in JSON5 format
224 * @param src list to store bookmarks
225 * @param path location of the file in UTF-8 encoding
226 * @param charset file encoding character set, NULL for default locale
227 * @return status of operation
228 */
229 status_t save_bookmarks(const lltl::parray<bookmark_t> *src, const char *path, const char *charset=NULL);
230
231 /**
232 * Save LSP bookmarks in JSON5 format
233 * @param src list to store bookmarks
234 * @param path location of the file
235 * @param charset file encoding character set, NULL for default locale
236 * @return status of operation
237 */
238 status_t save_bookmarks(const lltl::parray<bookmark_t> *src, const LSPString *path, const char *charset=NULL);
239
240 /**
241 * Save LSP bookmarks in JSON5 format
242 * @param src list to store bookmarks
243 * @param path location of the file
244 * @param charset file encoding character set, NULL for default locale
245 * @return status of operation
246 */
247 status_t save_bookmarks(const lltl::parray<bookmark_t> *src, const io::Path *path, const char *charset=NULL);
248
249 /**
250 * Save LSP bookmarks in JSON5 format
251 * @param src list to store bookmarks
252 * @param out output character sequence
253 * @return status of operation
254 */
255 status_t save_bookmarks(const lltl::parray<bookmark_t> *src, io::IOutSequence *out);
256
257 /**
258 * Merge bookmarks:
259 * - add all existing in src bookmarks to dst if they are non-existing in dst
260 * - set origin flag in dst to 'origin' for all bookmarks that exist in dst and origin
261 * - unset origin flsg in dst for all bookmarks that do not exist in src
262 * - remove all bookmarks that have zero origin
263 * @param dst destination storage of bookmarks
264 * @param src source change set
265 * @param origin origin flag associated with source
266 * @param changes pointer to integer to add number of changes
267 * @return status of operation
268 */
269 status_t merge_bookmarks(lltl::parray<bookmark_t> *dst, size_t *changes, const lltl::parray<bookmark_t> *src, bm_origin_t origin);
270
271 /**
272 * Destroy bookmarks
273 * @param list list of bookmarks
274 */
275 void destroy_bookmarks(lltl::parray<bookmark_t> *list);
276 }
277 }
278
279 #endif /* LSP_PLUG_IN_FMT_BOOKMARKS_H_ */