Mercurial > geeqie
annotate src/metadata.c @ 1219:86fcbd0fcb7b
added change notification to bar_info.c
author | nadvornik |
---|---|
date | Tue, 23 Dec 2008 20:53:44 +0000 |
parents | 46e4fda574dd |
children | a0c249bcc4ff |
rev | line source |
---|---|
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
1 /* |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
2 * Geeqie |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
3 * (C) 2004 John Ellis |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
4 * Copyright (C) 2008 The Geeqie Team |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
5 * |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
6 * Author: John Ellis, Laurent Monin |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
7 * |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
8 * This software is released under the GNU General Public License (GNU GPL). |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
9 * Please read the included file COPYING for more information. |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
10 * This software comes with no warranty of any kind, use at your own risk! |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
11 */ |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
12 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
13 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
14 #include "main.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
15 #include "metadata.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
16 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
17 #include "cache.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
18 #include "exif.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
19 #include "filedata.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
20 #include "misc.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
21 #include "secure_save.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
22 #include "ui_fileops.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
23 #include "ui_misc.h" |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
24 #include "utilops.h" |
1211 | 25 #include "filefilter.h" |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
26 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
27 typedef enum { |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
28 MK_NONE, |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
29 MK_KEYWORDS, |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
30 MK_COMMENT |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
31 } MetadataKey; |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
32 |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
33 #define COMMENT_KEY "Xmp.dc.description" |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
34 #define KEYWORD_KEY "Xmp.dc.subject" |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
35 |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
36 static gboolean metadata_write_queue_idle_cb(gpointer data); |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
37 static gint metadata_legacy_write(FileData *fd); |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
38 static gint metadata_legacy_delete(FileData *fd); |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
39 |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
40 |
1211 | 41 |
42 gboolean metadata_can_write_directly(FileData *fd) | |
43 { | |
44 return (filter_file_class(fd->extension, FORMAT_CLASS_IMAGE)); | |
45 /* FIXME: detect what exiv2 really supports */ | |
46 } | |
47 | |
48 gboolean metadata_can_write_sidecar(FileData *fd) | |
49 { | |
50 return (filter_file_class(fd->extension, FORMAT_CLASS_RAWIMAGE)); | |
51 /* FIXME: detect what exiv2 really supports */ | |
52 } | |
53 | |
54 | |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
55 /* |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
56 *------------------------------------------------------------------- |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
57 * write queue |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
58 *------------------------------------------------------------------- |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
59 */ |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
60 |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
61 static GList *metadata_write_queue = NULL; |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
62 static gint metadata_write_idle_id = -1; |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
63 |
1211 | 64 static FileData *metadata_xmp_sidecar_fd(FileData *fd) |
65 { | |
66 GList *work; | |
67 gchar *base, *new_name; | |
68 FileData *ret; | |
69 | |
70 if (!metadata_can_write_sidecar(fd)) return NULL; | |
71 | |
72 | |
73 if (fd->parent) fd = fd->parent; | |
74 | |
75 if (filter_file_class(fd->extension, FORMAT_CLASS_META)) | |
76 return file_data_ref(fd); | |
77 | |
78 work = fd->sidecar_files; | |
79 while (work) | |
80 { | |
81 FileData *sfd = work->data; | |
82 work = work->next; | |
83 if (filter_file_class(sfd->extension, FORMAT_CLASS_META)) | |
84 return file_data_ref(sfd); | |
85 } | |
86 | |
87 /* sidecar does not exist yet */ | |
88 base = remove_extension_from_path(fd->path); | |
89 new_name = g_strconcat(base, ".xmp", NULL); | |
90 g_free(base); | |
91 ret = file_data_new_simple(new_name); | |
92 g_free(new_name); | |
93 return ret; | |
94 } | |
95 | |
96 static FileData *metadata_xmp_main_fd(FileData *fd) | |
97 { | |
98 if (filter_file_class(fd->extension, FORMAT_CLASS_META) && !g_list_find(metadata_write_queue, fd)) | |
99 { | |
100 /* fd is a sidecar, we have to find the original file */ | |
101 | |
102 GList *work = metadata_write_queue; | |
103 while (work) | |
104 { | |
105 FileData *ofd = work->data; | |
106 FileData *osfd = metadata_xmp_sidecar_fd(ofd); | |
107 work = work->next; | |
108 file_data_unref(osfd); | |
109 if (fd == osfd) | |
110 { | |
111 return ofd; /* this is the main file */ | |
112 } | |
113 } | |
114 } | |
115 return NULL; | |
116 } | |
117 | |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
118 |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
119 static void metadata_write_queue_add(FileData *fd) |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
120 { |
1218 | 121 if (!g_list_find(metadata_write_queue, fd)) |
122 { | |
123 metadata_write_queue = g_list_prepend(metadata_write_queue, fd); | |
124 file_data_ref(fd); | |
125 } | |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
126 |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
127 if (metadata_write_idle_id != -1) |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
128 { |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
129 g_source_remove(metadata_write_idle_id); |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
130 metadata_write_idle_id = -1; |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
131 } |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
132 |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
133 if (options->metadata.confirm_timeout > 0) |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
134 { |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
135 metadata_write_idle_id = g_timeout_add(options->metadata.confirm_timeout * 1000, metadata_write_queue_idle_cb, NULL); |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
136 } |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
137 } |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
138 |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
139 |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
140 gboolean metadata_write_queue_remove(FileData *fd) |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
141 { |
1211 | 142 FileData *main_fd = metadata_xmp_main_fd(fd); |
143 | |
144 if (main_fd) fd = main_fd; | |
145 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
146 g_hash_table_destroy(fd->modified_xmp); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
147 fd->modified_xmp = NULL; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
148 |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
149 metadata_write_queue = g_list_remove(metadata_write_queue, fd); |
1211 | 150 |
151 file_data_increment_version(fd); | |
152 file_data_send_notification(fd, NOTIFY_TYPE_REREAD); | |
153 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
154 file_data_unref(fd); |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
155 return TRUE; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
156 } |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
157 |
1211 | 158 gboolean metadata_write_queue_remove_list(GList *list) |
159 { | |
160 GList *work; | |
161 gboolean ret = TRUE; | |
162 | |
163 work = list; | |
164 while (work) | |
165 { | |
166 FileData *fd = work->data; | |
167 work = work->next; | |
168 ret = ret && metadata_write_queue_remove(fd); | |
169 } | |
170 return ret; | |
171 } | |
172 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
173 |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
174 gboolean metadata_write_queue_confirm() |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
175 { |
1211 | 176 GList *work; |
177 GList *to_approve = NULL; | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
178 |
1211 | 179 work = metadata_write_queue; |
180 while (work) | |
181 { | |
182 FileData *fd = work->data; | |
183 work = work->next; | |
184 | |
185 if (fd->change) continue; /* another operation in progress, skip this file for now */ | |
186 | |
187 FileData *to_approve_fd = metadata_xmp_sidecar_fd(fd); | |
188 | |
189 if (!to_approve_fd) to_approve_fd = file_data_ref(fd); /* this is not a sidecar */ | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
190 |
1211 | 191 to_approve = g_list_prepend(to_approve, to_approve_fd); |
192 } | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
193 |
1211 | 194 file_util_write_metadata(NULL, to_approve, NULL); |
195 | |
196 filelist_free(to_approve); | |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
197 |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
198 return (metadata_write_queue != NULL); |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
199 } |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
200 |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
201 static gboolean metadata_write_queue_idle_cb(gpointer data) |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
202 { |
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
203 metadata_write_queue_confirm(); |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
204 metadata_write_idle_id = -1; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
205 return FALSE; |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
206 } |
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
207 |
1214
31402ecb2aed
write metadata after timeout, image change or dir change
nadvornik
parents:
1211
diff
changeset
|
208 |
1211 | 209 gboolean metadata_write_exif(FileData *fd, FileData *sfd) |
210 { | |
211 gboolean success; | |
212 ExifData *exif; | |
213 | |
214 /* we can either use cached metadata which have fd->modified_xmp already applied | |
215 or read metadata from file and apply fd->modified_xmp | |
216 metadata are read also if the file was modified meanwhile */ | |
217 exif = exif_read_fd(fd); | |
218 if (!exif) return FALSE; | |
219 success = sfd ? exif_write_sidecar(exif, sfd->path) : exif_write(exif); /* write modified metadata */ | |
220 exif_free_fd(fd, exif); | |
221 return success; | |
222 } | |
223 | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
224 gboolean metadata_write_perform(FileData *fd) |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
225 { |
1211 | 226 FileData *sfd = NULL; |
227 FileData *main_fd = metadata_xmp_main_fd(fd); | |
228 | |
229 if (main_fd) | |
230 { | |
231 sfd = fd; | |
232 fd = main_fd; | |
233 } | |
234 | |
1208 | 235 if (options->metadata.save_in_image_file && |
1211 | 236 metadata_write_exif(fd, sfd)) |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
237 { |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
238 metadata_legacy_delete(fd); |
1211 | 239 if (sfd) metadata_legacy_delete(sfd); |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
240 } |
1211 | 241 else |
242 { | |
243 metadata_legacy_write(fd); | |
244 } | |
1205
3ff2aa99108b
use the workflow in utilops.c for metadata approving and writting
nadvornik
parents:
1204
diff
changeset
|
245 return TRUE; |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
246 } |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
247 |
1203
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
248 gint metadata_write_list(FileData *fd, const gchar *key, GList *values) |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
249 { |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
250 if (!fd->modified_xmp) |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
251 { |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
252 fd->modified_xmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)string_list_free); |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
253 } |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
254 g_hash_table_insert(fd->modified_xmp, g_strdup(key), values); |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
255 if (fd->exif) |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
256 { |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
257 exif_update_metadata(fd->exif, key, values); |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
258 } |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
259 metadata_write_queue_add(fd); |
1218 | 260 file_data_increment_version(fd); |
261 file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); | |
262 | |
1203
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
263 return TRUE; |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
264 } |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
265 |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
266 gint metadata_write_string(FileData *fd, const gchar *key, const char *value) |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
267 { |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
268 return metadata_write_list(fd, key, g_list_append(NULL, g_strdup(value))); |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
269 } |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
270 |
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
271 |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
272 /* |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
273 *------------------------------------------------------------------- |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
274 * keyword / comment read/write |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
275 *------------------------------------------------------------------- |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
276 */ |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
277 |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
278 static gint metadata_file_write(gchar *path, GHashTable *modified_xmp) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
279 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
280 SecureSaveInfo *ssi; |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
281 GList *keywords = g_hash_table_lookup(modified_xmp, KEYWORD_KEY); |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
282 GList *comment_l = g_hash_table_lookup(modified_xmp, COMMENT_KEY); |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
283 gchar *comment = comment_l ? comment_l->data : NULL; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
284 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
285 ssi = secure_open(path); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
286 if (!ssi) return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
287 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
288 secure_fprintf(ssi, "#%s comment (%s)\n\n", GQ_APPNAME, VERSION); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
289 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
290 secure_fprintf(ssi, "[keywords]\n"); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
291 while (keywords && secsave_errno == SS_ERR_NONE) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
292 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
293 const gchar *word = keywords->data; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
294 keywords = keywords->next; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
295 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
296 secure_fprintf(ssi, "%s\n", word); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
297 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
298 secure_fputc(ssi, '\n'); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
299 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
300 secure_fprintf(ssi, "[comment]\n"); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
301 secure_fprintf(ssi, "%s\n", (comment) ? comment : ""); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
302 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
303 secure_fprintf(ssi, "#end\n"); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
304 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
305 return (secure_close(ssi) == 0); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
306 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
307 |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
308 static gint metadata_legacy_write(FileData *fd) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
309 { |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
310 gchar *metadata_path; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
311 gint success = FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
312 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
313 /* If an existing metadata file exists, we will try writing to |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
314 * it's location regardless of the user's preference. |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
315 */ |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
316 metadata_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
317 if (metadata_path && !access_file(metadata_path, W_OK)) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
318 { |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
319 g_free(metadata_path); |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
320 metadata_path = NULL; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
321 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
322 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
323 if (!metadata_path) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
324 { |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
325 gchar *metadata_dir; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
326 mode_t mode = 0755; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
327 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
328 metadata_dir = cache_get_location(CACHE_TYPE_METADATA, fd->path, FALSE, &mode); |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
329 if (recursive_mkdir_if_not_exists(metadata_dir, mode)) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
330 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
331 gchar *filename = g_strconcat(fd->name, GQ_CACHE_EXT_METADATA, NULL); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
332 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
333 metadata_path = g_build_filename(metadata_dir, filename, NULL); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
334 g_free(filename); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
335 } |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
336 g_free(metadata_dir); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
337 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
338 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
339 if (metadata_path) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
340 { |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
341 gchar *metadata_pathl; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
342 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
343 DEBUG_1("Saving comment: %s", metadata_path); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
344 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
345 metadata_pathl = path_from_utf8(metadata_path); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
346 |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
347 success = metadata_file_write(metadata_pathl, fd->modified_xmp); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
348 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
349 g_free(metadata_pathl); |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
350 g_free(metadata_path); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
351 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
352 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
353 return success; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
354 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
355 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
356 static gint metadata_file_read(gchar *path, GList **keywords, gchar **comment) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
357 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
358 FILE *f; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
359 gchar s_buf[1024]; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
360 MetadataKey key = MK_NONE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
361 GList *list = NULL; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
362 GString *comment_build = NULL; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
363 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
364 f = fopen(path, "r"); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
365 if (!f) return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
366 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
367 while (fgets(s_buf, sizeof(s_buf), f)) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
368 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
369 gchar *ptr = s_buf; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
370 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
371 if (*ptr == '#') continue; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
372 if (*ptr == '[' && key != MK_COMMENT) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
373 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
374 gchar *keystr = ++ptr; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
375 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
376 key = MK_NONE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
377 while (*ptr != ']' && *ptr != '\n' && *ptr != '\0') ptr++; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
378 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
379 if (*ptr == ']') |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
380 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
381 *ptr = '\0'; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
382 if (g_ascii_strcasecmp(keystr, "keywords") == 0) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
383 key = MK_KEYWORDS; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
384 else if (g_ascii_strcasecmp(keystr, "comment") == 0) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
385 key = MK_COMMENT; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
386 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
387 continue; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
388 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
389 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
390 switch(key) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
391 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
392 case MK_NONE: |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
393 break; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
394 case MK_KEYWORDS: |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
395 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
396 while (*ptr != '\n' && *ptr != '\0') ptr++; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
397 *ptr = '\0'; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
398 if (strlen(s_buf) > 0) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
399 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
400 gchar *kw = utf8_validate_or_convert(s_buf); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
401 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
402 list = g_list_prepend(list, kw); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
403 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
404 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
405 break; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
406 case MK_COMMENT: |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
407 if (!comment_build) comment_build = g_string_new(""); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
408 g_string_append(comment_build, s_buf); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
409 break; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
410 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
411 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
412 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
413 fclose(f); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
414 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
415 *keywords = g_list_reverse(list); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
416 if (comment_build) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
417 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
418 if (comment) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
419 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
420 gint len; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
421 gchar *ptr = comment_build->str; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
422 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
423 /* strip leading and trailing newlines */ |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
424 while (*ptr == '\n') ptr++; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
425 len = strlen(ptr); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
426 while (len > 0 && ptr[len - 1] == '\n') len--; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
427 if (ptr[len] == '\n') len++; /* keep the last one */ |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
428 if (len > 0) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
429 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
430 gchar *text = g_strndup(ptr, len); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
431 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
432 *comment = utf8_validate_or_convert(text); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
433 g_free(text); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
434 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
435 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
436 g_string_free(comment_build, TRUE); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
437 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
438 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
439 return TRUE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
440 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
441 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
442 static gint metadata_legacy_delete(FileData *fd) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
443 { |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
444 gchar *metadata_path; |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
445 gchar *metadata_pathl; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
446 gint success = FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
447 if (!fd) return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
448 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
449 metadata_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
450 if (!metadata_path) return FALSE; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
451 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
452 metadata_pathl = path_from_utf8(metadata_path); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
453 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
454 success = !unlink(metadata_pathl); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
455 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
456 g_free(metadata_pathl); |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
457 g_free(metadata_path); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
458 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
459 return success; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
460 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
461 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
462 static gint metadata_legacy_read(FileData *fd, GList **keywords, gchar **comment) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
463 { |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
464 gchar *metadata_path; |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
465 gchar *metadata_pathl; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
466 gint success = FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
467 if (!fd) return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
468 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
469 metadata_path = cache_find_location(CACHE_TYPE_METADATA, fd->path); |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
470 if (!metadata_path) return FALSE; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
471 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
472 metadata_pathl = path_from_utf8(metadata_path); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
473 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
474 success = metadata_file_read(metadata_pathl, keywords, comment); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
475 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
476 g_free(metadata_pathl); |
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
477 g_free(metadata_path); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
478 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
479 return success; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
480 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
481 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
482 static GList *remove_duplicate_strings_from_list(GList *list) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
483 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
484 GList *work = list; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
485 GHashTable *hashtable = g_hash_table_new(g_str_hash, g_str_equal); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
486 GList *newlist = NULL; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
487 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
488 while (work) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
489 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
490 gchar *key = work->data; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
491 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
492 if (g_hash_table_lookup(hashtable, key) == NULL) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
493 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
494 g_hash_table_insert(hashtable, (gpointer) key, GINT_TO_POINTER(1)); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
495 newlist = g_list_prepend(newlist, key); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
496 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
497 work = work->next; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
498 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
499 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
500 g_hash_table_destroy(hashtable); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
501 g_list_free(list); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
502 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
503 return g_list_reverse(newlist); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
504 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
505 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
506 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
507 static gint metadata_xmp_read(FileData *fd, GList **keywords, gchar **comment) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
508 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
509 ExifData *exif; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
510 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
511 exif = exif_read_fd(fd); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
512 if (!exif) return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
513 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
514 if (comment) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
515 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
516 gchar *text; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
517 ExifItem *item = exif_get_item(exif, COMMENT_KEY); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
518 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
519 text = exif_item_get_string(item, 0); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
520 *comment = utf8_validate_or_convert(text); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
521 g_free(text); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
522 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
523 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
524 if (keywords) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
525 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
526 ExifItem *item; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
527 guint i; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
528 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
529 *keywords = NULL; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
530 item = exif_get_item(exif, KEYWORD_KEY); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
531 for (i = 0; i < exif_item_get_elements(item); i++) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
532 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
533 gchar *kw = exif_item_get_string(item, i); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
534 gchar *utf8_kw; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
535 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
536 if (!kw) break; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
537 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
538 utf8_kw = utf8_validate_or_convert(kw); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
539 *keywords = g_list_append(*keywords, (gpointer) utf8_kw); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
540 g_free(kw); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
541 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
542 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
543 /* FIXME: |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
544 * Exiv2 handles Iptc keywords as multiple entries with the |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
545 * same key, thus exif_get_item returns only the first keyword |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
546 * and the only way to get all keywords is to iterate through |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
547 * the item list. |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
548 */ |
1219 | 549 /* Read IPTC keywords only if there are no XMP keywords |
550 * IPTC does not have standard charset, thus the encoding may differ | |
551 * from XMP and keyword merging is not reliable. | |
552 */ | |
553 if (!*keywords) | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
554 { |
1219 | 555 for (item = exif_get_first_item(exif); |
556 item; | |
557 item = exif_get_next_item(exif)) | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
558 { |
1219 | 559 guint tag; |
560 | |
561 tag = exif_item_get_tag_id(item); | |
562 if (tag == 0x0019) | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
563 { |
1219 | 564 gchar *tag_name = exif_item_get_tag_name(item); |
565 | |
566 if (strcmp(tag_name, "Iptc.Application2.Keywords") == 0) | |
567 { | |
568 gchar *kw; | |
569 gchar *utf8_kw; | |
570 | |
571 kw = exif_item_get_data_as_text(item); | |
572 if (!kw) continue; | |
573 | |
574 utf8_kw = utf8_validate_or_convert(kw); | |
575 *keywords = g_list_append(*keywords, (gpointer) utf8_kw); | |
576 g_free(kw); | |
577 } | |
578 g_free(tag_name); | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
579 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
580 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
581 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
582 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
583 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
584 exif_free_fd(fd, exif); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
585 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
586 return (comment && *comment) || (keywords && *keywords); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
587 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
588 |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
589 gint metadata_write(FileData *fd, GList *keywords, const gchar *comment) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
590 { |
1203
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
591 gint success = TRUE; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
592 gint write_comment = (comment && comment[0]); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
593 |
1204
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
594 if (!fd) return FALSE; |
fa91098e4949
queue metadata and write them in an idle callback
nadvornik
parents:
1203
diff
changeset
|
595 |
1203
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
596 if (write_comment) success = success && metadata_write_string(fd, COMMENT_KEY, comment); |
1211 | 597 if (keywords) success = success && metadata_write_list(fd, KEYWORD_KEY, string_list_copy(keywords)); |
1203
43bfcbb62cd6
prepared infrastructure for delayed metadata writting - refreshing
nadvornik
parents:
1194
diff
changeset
|
598 |
1211 | 599 if (options->metadata.sync_grouped_files) |
600 { | |
601 GList *work = fd->sidecar_files; | |
602 | |
603 while (work) | |
604 { | |
605 FileData *sfd = work->data; | |
606 work = work->next; | |
607 | |
608 if (filter_file_class(sfd->extension, FORMAT_CLASS_META)) continue; | |
609 | |
610 if (write_comment) success = success && metadata_write_string(sfd, COMMENT_KEY, comment); | |
611 if (keywords) success = success && metadata_write_list(sfd, KEYWORD_KEY, string_list_copy(keywords)); | |
612 } | |
613 } | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
614 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
615 return success; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
616 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
617 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
618 gint metadata_read(FileData *fd, GList **keywords, gchar **comment) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
619 { |
1194 | 620 GList *keywords_xmp = NULL; |
621 GList *keywords_legacy = NULL; | |
622 gchar *comment_xmp = NULL; | |
623 gchar *comment_legacy = NULL; | |
624 gint result_xmp, result_legacy; | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
625 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
626 if (!fd) return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
627 |
1194 | 628 result_xmp = metadata_xmp_read(fd, &keywords_xmp, &comment_xmp); |
629 result_legacy = metadata_legacy_read(fd, &keywords_legacy, &comment_legacy); | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
630 |
1194 | 631 if (!result_xmp && !result_legacy) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
632 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
633 return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
634 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
635 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
636 if (keywords) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
637 { |
1194 | 638 if (result_xmp && result_legacy) |
639 *keywords = g_list_concat(keywords_xmp, keywords_legacy); | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
640 else |
1194 | 641 *keywords = result_xmp ? keywords_xmp : keywords_legacy; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
642 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
643 *keywords = remove_duplicate_strings_from_list(*keywords); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
644 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
645 else |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
646 { |
1194 | 647 if (result_xmp) string_list_free(keywords_xmp); |
648 if (result_legacy) string_list_free(keywords_legacy); | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
649 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
650 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
651 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
652 if (comment) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
653 { |
1194 | 654 if (result_xmp && result_legacy && comment_xmp && comment_legacy && *comment_xmp && *comment_legacy) |
655 *comment = g_strdup_printf("%s\n%s", comment_xmp, comment_legacy); | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
656 else |
1194 | 657 *comment = result_xmp ? comment_xmp : comment_legacy; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
658 } |
1194 | 659 |
660 if (result_xmp && (!comment || *comment != comment_xmp)) g_free(comment_xmp); | |
661 if (result_legacy && (!comment || *comment != comment_legacy)) g_free(comment_legacy); | |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
662 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
663 // return FALSE in the following cases: |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
664 // - only looking for a comment and didn't find one |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
665 // - only looking for keywords and didn't find any |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
666 // - looking for either a comment or keywords, but found nothing |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
667 if ((!keywords && comment && !*comment) || |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
668 (!comment && keywords && !*keywords) || |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
669 ( comment && !*comment && keywords && !*keywords)) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
670 return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
671 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
672 return TRUE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
673 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
674 |
1194 | 675 void metadata_set(FileData *fd, GList *new_keywords, gchar *new_comment, gboolean append) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
676 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
677 gchar *comment = NULL; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
678 GList *keywords = NULL; |
1194 | 679 GList *keywords_list = NULL; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
680 |
1191
bb02d0e2a573
Rename most comment_*() functions to more appropriate metadata_*().
zas_
parents:
1178
diff
changeset
|
681 metadata_read(fd, &keywords, &comment); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
682 |
1194 | 683 if (new_comment) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
684 { |
1192
48d62a7e3c33
metadata_set_keywords() -> metadata_set(). Use gboolean type for boolean parameters.
zas_
parents:
1191
diff
changeset
|
685 if (append && comment && *comment) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
686 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
687 gchar *tmp = comment; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
688 |
1194 | 689 comment = g_strconcat(tmp, new_comment, NULL); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
690 g_free(tmp); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
691 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
692 else |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
693 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
694 g_free(comment); |
1194 | 695 comment = g_strdup(new_comment); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
696 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
697 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
698 |
1194 | 699 if (new_keywords) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
700 { |
1192
48d62a7e3c33
metadata_set_keywords() -> metadata_set(). Use gboolean type for boolean parameters.
zas_
parents:
1191
diff
changeset
|
701 if (append && keywords && g_list_length(keywords) > 0) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
702 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
703 GList *work; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
704 |
1194 | 705 work = new_keywords; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
706 while (work) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
707 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
708 gchar *key; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
709 GList *p; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
710 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
711 key = work->data; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
712 work = work->next; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
713 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
714 p = keywords; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
715 while (p && key) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
716 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
717 gchar *needle = p->data; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
718 p = p->next; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
719 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
720 if (strcmp(needle, key) == 0) key = NULL; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
721 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
722 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
723 if (key) keywords = g_list_append(keywords, g_strdup(key)); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
724 } |
1194 | 725 keywords_list = keywords; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
726 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
727 else |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
728 { |
1194 | 729 keywords_list = new_keywords; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
730 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
731 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
732 |
1194 | 733 metadata_write(fd, keywords_list, comment); |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
734 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
735 string_list_free(keywords); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
736 g_free(comment); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
737 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
738 |
1193
aed0e28b2744
keyword_list_find() -> find_string_in_list(), return gboolean.
zas_
parents:
1192
diff
changeset
|
739 gboolean find_string_in_list(GList *list, const gchar *string) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
740 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
741 while (list) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
742 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
743 gchar *haystack = list->data; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
744 |
1193
aed0e28b2744
keyword_list_find() -> find_string_in_list(), return gboolean.
zas_
parents:
1192
diff
changeset
|
745 if (haystack && string && strcmp(haystack, string) == 0) return TRUE; |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
746 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
747 list = list->next; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
748 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
749 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
750 return FALSE; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
751 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
752 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
753 #define KEYWORDS_SEPARATOR(c) ((c) == ',' || (c) == ';' || (c) == '\n' || (c) == '\r' || (c) == '\b') |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
754 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
755 GList *string_to_keywords_list(const gchar *text) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
756 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
757 GList *list = NULL; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
758 const gchar *ptr = text; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
759 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
760 while (*ptr != '\0') |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
761 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
762 const gchar *begin; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
763 gint l = 0; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
764 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
765 while (KEYWORDS_SEPARATOR(*ptr)) ptr++; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
766 begin = ptr; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
767 while (*ptr != '\0' && !KEYWORDS_SEPARATOR(*ptr)) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
768 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
769 ptr++; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
770 l++; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
771 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
772 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
773 /* trim starting and ending whitespaces */ |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
774 while (l > 0 && g_ascii_isspace(*begin)) begin++, l--; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
775 while (l > 0 && g_ascii_isspace(begin[l-1])) l--; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
776 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
777 if (l > 0) |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
778 { |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
779 gchar *keyword = g_strndup(begin, l); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
780 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
781 /* only add if not already in the list */ |
1193
aed0e28b2744
keyword_list_find() -> find_string_in_list(), return gboolean.
zas_
parents:
1192
diff
changeset
|
782 if (find_string_in_list(list, keyword) == FALSE) |
1178
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
783 list = g_list_append(list, keyword); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
784 else |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
785 g_free(keyword); |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
786 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
787 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
788 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
789 return list; |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
790 } |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
791 |
f6449c17306b
Move comments/keywords read and write stuff to new metadata.{c,h}.
zas_
parents:
diff
changeset
|
792 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |