1 |
commit: 770600b673ace427b6e17072439149b1764ef7f0 |
2 |
Author: Andreas K. Huettel (dilfridge) <mail <AT> akhuettel <DOT> de> |
3 |
AuthorDate: Sun Apr 3 17:09:57 2011 +0000 |
4 |
Commit: Andreas K. Huettel <dilfridge <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Apr 3 17:09:57 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/kde.git;a=commit;h=770600b6 |
7 |
|
8 |
[kde-base/kdelibs] Add upstream patch: KFileMetaDataProvider: Don't crash if a Strigi analyzer crashes |
9 |
|
10 |
Some Strigi analyzers are still unstable and crash under certain circumstances. |
11 |
This patch moves the reading of the meta-data into a custom process instead of |
12 |
doing it in a thread, which assures that a crashing Strigi analyzer does not |
13 |
result in crashing Dolphin or Konqueror when hovering some items. |
14 |
|
15 |
(Portage version: 2.1.9.45/git/Linux x86_64, signed Manifest commit with key B6C5F7DE) |
16 |
|
17 |
--- |
18 |
.../kdelibs/files/kdelibs-4.6.2-safestrigi.patch | 780 ++++++++++++++++++++ |
19 |
kde-base/kdelibs/kdelibs-4.6.2.ebuild | 1 + |
20 |
kde-base/kdelibs/kdelibs-4.6.9999.ebuild | 1 + |
21 |
3 files changed, 782 insertions(+), 0 deletions(-) |
22 |
|
23 |
diff --git a/kde-base/kdelibs/files/kdelibs-4.6.2-safestrigi.patch b/kde-base/kdelibs/files/kdelibs-4.6.2-safestrigi.patch |
24 |
new file mode 100644 |
25 |
index 0000000..f6c1828 |
26 |
--- /dev/null |
27 |
+++ b/kde-base/kdelibs/files/kdelibs-4.6.2-safestrigi.patch |
28 |
@@ -0,0 +1,780 @@ |
29 |
+commit d1254968eac95f4d9d8c47552e27f0cc40e6aed9 |
30 |
+Author: Peter Penz <peter.penz19@×××××.com> |
31 |
+Date: Sun Feb 27 20:01:19 2011 +0100 |
32 |
+ |
33 |
+ KFileMetaDataProvider: Don't crash if a Strigi analyzer crashes |
34 |
+ |
35 |
+ Some Strigi analyzers are still unstable and crash under certain circumstances. This patch moves the reading of the meta-data into a custom process instead of doing it in a thread, which assures that a crashing Strigi analyzer does not result in crashing Dolphin or Konqueror when hovering some items. |
36 |
+ |
37 |
+ FIXED-IN: 4.7.0 |
38 |
+ BUG: 257964 |
39 |
+ BUG: 258715 |
40 |
+ BUG: 262299 |
41 |
+ BUG: 263468 |
42 |
+ BUG: 263502 |
43 |
+ BUG: 264254 |
44 |
+ BUG: 234799 |
45 |
+ BUG: 251462 |
46 |
+ BUG: 251701 |
47 |
+ BUG: 258918 |
48 |
+ BUG: 192377 |
49 |
+ BUG: 195564 |
50 |
+ BUG: 199368 |
51 |
+ BUG: 210841 |
52 |
+ BUG: 245376 |
53 |
+ BUG: 246461 |
54 |
+ BUG: 246901 |
55 |
+ BUG: 249150 |
56 |
+ BUG: 261952 |
57 |
+ BUG: 249876 |
58 |
+ BUG: 179376 |
59 |
+ BUG: 179417 |
60 |
+ BUG: 179420 |
61 |
+ BUG: 181591 |
62 |
+ BUG: 183269 |
63 |
+ BUG: 183722 |
64 |
+ BUG: 185667 |
65 |
+ BUG: 188596 |
66 |
+ BUG: 191864 |
67 |
+ BUG: 193112 |
68 |
+ BUG: 205813 |
69 |
+ BUG: 244621 |
70 |
+ BUG: 245451 |
71 |
+ BUG: 248214 |
72 |
+ BUG: 249655 |
73 |
+ BUG: 249876 |
74 |
+ BUG: 265549 |
75 |
+ BUG: 267079 |
76 |
+ |
77 |
+diff --git a/kio/CMakeLists.txt b/kio/CMakeLists.txt |
78 |
+index 0802150..72386f8 100644 |
79 |
+--- a/kio/CMakeLists.txt |
80 |
++++ b/kio/CMakeLists.txt |
81 |
+@@ -257,7 +257,6 @@ if(NOT KIO_NO_NEPOMUK) |
82 |
+ set(kfile_STAT_SRCS |
83 |
+ ${kfile_STAT_SRCS} |
84 |
+ kfile/kcommentwidget.cpp |
85 |
+- kfile/kloadfilemetadatathread.cpp |
86 |
+ ) |
87 |
+ endif(NOT KIO_NO_NEPOMUK) |
88 |
+ |
89 |
+@@ -307,6 +306,12 @@ set(kio_LIB_PRIVATE_SRCS |
90 |
+ kio/slaveinterface_p.h |
91 |
+ ) |
92 |
+ |
93 |
++if(NOT KIO_NO_NEPOMUK) |
94 |
++ set(kfilemetadatareader_SRCS |
95 |
++ kfile/kfilemetadatareader.cpp |
96 |
++ ) |
97 |
++endif(NOT KIO_NO_NEPOMUK) |
98 |
++ |
99 |
+ kde4_add_ui_files(kio_LIB_SRCS |
100 |
+ kfile/kpropertiesdesktopadvbase.ui |
101 |
+ kfile/kpropertiesdesktopbase.ui |
102 |
+@@ -323,6 +328,8 @@ install(FILES kssl/ksslcertificatemanager.upd |
103 |
+ kde4_add_library(kio ${LIBRARY_TYPE} ${kio_LIB_SRCS}) |
104 |
+ |
105 |
+ if(NOT KIO_NO_NEPOMUK) |
106 |
++ kde4_add_executable(kfilemetadatareader ${kfilemetadatareader_SRCS}) |
107 |
++ target_link_libraries(kfilemetadatareader ${KDE4_KIO_LIBS} ${KDE4_NEPOMUK_LIBRARY} nepomukutils) |
108 |
+ target_link_libraries(kio ${KDE4_NEPOMUK_LIBRARY} nepomukquery nepomukutils) |
109 |
+ endif(NOT KIO_NO_NEPOMUK) |
110 |
+ target_link_libraries(kio ${KDE4_KDEUI_LIBS} ${ZLIB_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTSVG_LIBRARY} ${X11_LIBRARIES} ${KIO_EXTRA_LIBS}) |
111 |
+@@ -343,6 +350,9 @@ set_target_properties(kio PROPERTIES VERSION ${KDE_NON_GENERIC_LIB_VERSION} |
112 |
+ |
113 |
+ ########### install files ############### |
114 |
+ install(TARGETS kio EXPORT kdelibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) |
115 |
++if(NOT KIO_NO_NEPOMUK) |
116 |
++ install(TARGETS kfilemetadatareader ${INSTALL_TARGETS_DEFAULT_ARGS}) |
117 |
++endif(NOT KIO_NO_NEPOMUK) |
118 |
+ |
119 |
+ install( PROGRAMS useragent.pl proxytype.pl DESTINATION ${KCONF_UPDATE_INSTALL_DIR} ) |
120 |
+ |
121 |
+diff --git a/kio/kfile/kfilemetadataprovider.cpp b/kio/kfile/kfilemetadataprovider.cpp |
122 |
+index 09ce4b2..d6e4d0d 100644 |
123 |
+--- a/kio/kfile/kfilemetadataprovider.cpp |
124 |
++++ b/kio/kfile/kfilemetadataprovider.cpp |
125 |
+@@ -22,18 +22,20 @@ |
126 |
+ #include <kfileitem.h> |
127 |
+ #include "knfotranslator_p.h" |
128 |
+ #include <klocale.h> |
129 |
++#include <kprocess.h> |
130 |
++#include <kstandarddirs.h> |
131 |
+ #include <kurl.h> |
132 |
+ |
133 |
+ #ifndef KIO_NO_NEPOMUK |
134 |
+ #define DISABLE_NEPOMUK_LEGACY |
135 |
+ #include "nepomukmassupdatejob.h" |
136 |
+ #include "tagwidget.h" |
137 |
++ #include "tag.h" |
138 |
+ #include "kratingwidget.h" |
139 |
+ #include "resource.h" |
140 |
+ #include "resourcemanager.h" |
141 |
+ |
142 |
+ #include "kcommentwidget_p.h" |
143 |
+- #include "kloadfilemetadatathread_p.h" |
144 |
+ #else |
145 |
+ namespace Nepomuk |
146 |
+ { |
147 |
+@@ -103,7 +105,7 @@ public: |
148 |
+ Private(KFileMetaDataProvider* parent); |
149 |
+ ~Private(); |
150 |
+ |
151 |
+- void slotLoadingFinished(QThread* finishedThread); |
152 |
++ void slotLoadingFinished(int exitCode, QProcess::ExitStatus exitStatus); |
153 |
+ |
154 |
+ void slotRatingChanged(unsigned int rating); |
155 |
+ void slotTagsChanged(const QList<Nepomuk::Tag>& tags); |
156 |
+@@ -135,8 +137,8 @@ public: |
157 |
+ #ifndef KIO_NO_NEPOMUK |
158 |
+ QHash<KUrl, Nepomuk::Variant> m_data; |
159 |
+ |
160 |
+- QList<KLoadFileMetaDataThread*> m_metaDataThreads; |
161 |
+- KLoadFileMetaDataThread* m_latestMetaDataThread; |
162 |
++ QList<KProcess*> m_metaDataProcesses; |
163 |
++ KProcess* m_latestMetaDataProcess; |
164 |
+ |
165 |
+ QWeakPointer<KRatingWidget> m_ratingWidget; |
166 |
+ QWeakPointer<Nepomuk::TagWidget> m_tagWidget; |
167 |
+@@ -153,8 +155,8 @@ KFileMetaDataProvider::Private::Private(KFileMetaDataProvider* parent) : |
168 |
+ m_fileItems(), |
169 |
+ #ifndef KIO_NO_NEPOMUK |
170 |
+ m_data(), |
171 |
+- m_metaDataThreads(), |
172 |
+- m_latestMetaDataThread(0), |
173 |
++ m_metaDataProcesses(), |
174 |
++ m_latestMetaDataProcess(0), |
175 |
+ m_ratingWidget(), |
176 |
+ m_tagWidget(), |
177 |
+ m_commentWidget(), |
178 |
+@@ -169,35 +171,57 @@ KFileMetaDataProvider::Private::Private(KFileMetaDataProvider* parent) : |
179 |
+ KFileMetaDataProvider::Private::~Private() |
180 |
+ { |
181 |
+ #ifndef KIO_NO_NEPOMUK |
182 |
+- foreach (KLoadFileMetaDataThread* thread, m_metaDataThreads) { |
183 |
+- disconnect(thread, SIGNAL(finished(QThread*)), |
184 |
+- q, SLOT(slotLoadingFinished(QThread*))); |
185 |
+- thread->wait(); |
186 |
+- } |
187 |
++ qDeleteAll(m_metaDataProcesses); |
188 |
+ #endif |
189 |
+ } |
190 |
+ |
191 |
+-void KFileMetaDataProvider::Private::slotLoadingFinished(QThread* finishedThread) |
192 |
++void KFileMetaDataProvider::Private::slotLoadingFinished(int exitCode, QProcess::ExitStatus exitStatus) |
193 |
+ { |
194 |
++ Q_UNUSED(exitCode); |
195 |
++ Q_UNUSED(exitStatus); |
196 |
++ |
197 |
+ #ifndef KIO_NO_NEPOMUK |
198 |
+- // The thread that has emitted the finished() signal |
199 |
+- // will get deleted and removed from m_metaDataThreads. |
200 |
+- const int threadsCount = m_metaDataThreads.count(); |
201 |
+- for (int i = 0; i < threadsCount; ++i) { |
202 |
+- KLoadFileMetaDataThread* thread = m_metaDataThreads[i]; |
203 |
+- if (thread == finishedThread) { |
204 |
+- m_metaDataThreads.removeAt(i); |
205 |
+- if (thread != m_latestMetaDataThread) { |
206 |
+- // Ignore data of older threads, as the data got |
207 |
+- // obsolete by m_latestMetaDataThread. |
208 |
+- thread->deleteLater(); |
209 |
++ KProcess* finishedProcess = qobject_cast<KProcess*>(q->sender()); |
210 |
++ // The process that has emitted the finished() signal |
211 |
++ // will get deleted and removed from m_metaDataProcesses. |
212 |
++ for (int i = 0; i < m_metaDataProcesses.count(); ++i) { |
213 |
++ KProcess* process = m_metaDataProcesses[i]; |
214 |
++ if (process == finishedProcess) { |
215 |
++ m_metaDataProcesses.removeAt(i); |
216 |
++ if (process != m_latestMetaDataProcess) { |
217 |
++ // Ignore data of older processs, as the data got |
218 |
++ // obsolete by m_latestMetaDataProcess. |
219 |
++ process->deleteLater(); |
220 |
+ return; |
221 |
+ } |
222 |
+ } |
223 |
+ } |
224 |
+ |
225 |
+- m_data = m_latestMetaDataThread->data(); |
226 |
+- m_latestMetaDataThread->deleteLater(); |
227 |
++ m_data.clear(); |
228 |
++ while (m_latestMetaDataProcess->canReadLine()) { |
229 |
++ // Read key |
230 |
++ QString key = QString::fromLocal8Bit(m_latestMetaDataProcess->readLine()); |
231 |
++ key.remove(QChar::Other_Control); |
232 |
++ |
233 |
++ // Read variant-type |
234 |
++ if (!m_latestMetaDataProcess->canReadLine()) { |
235 |
++ break; |
236 |
++ } |
237 |
++ QString valueTypeString(QString::fromLocal8Bit(m_latestMetaDataProcess->readLine())); |
238 |
++ valueTypeString.remove(QChar::Other_Control); |
239 |
++ const int valueType = valueTypeString.toInt(); |
240 |
++ if (!m_latestMetaDataProcess->canReadLine()) { |
241 |
++ break; |
242 |
++ } |
243 |
++ |
244 |
++ // Read variant-value |
245 |
++ QString value(QString::fromLocal8Bit(m_latestMetaDataProcess->readLine())); |
246 |
++ value.remove(QChar::Other_Control); |
247 |
++ // TODO: Handle value-types like QVariantList |
248 |
++ Q_UNUSED(valueType); |
249 |
++ m_data.insert(KUrl(key), value); |
250 |
++ } |
251 |
++ m_latestMetaDataProcess->deleteLater(); |
252 |
+ |
253 |
+ if (m_fileItems.count() == 1) { |
254 |
+ // TODO: Handle case if remote URLs are used properly. isDir() does |
255 |
+@@ -219,14 +243,11 @@ void KFileMetaDataProvider::Private::slotLoadingFinished(QThread* finishedThread |
256 |
+ } |
257 |
+ m_data.insert(KUrl("kfileitem#totalSize"), KIO::convertSize(totalSize)); |
258 |
+ } |
259 |
+-#else |
260 |
+- Q_UNUSED(finishedThread) |
261 |
+ #endif |
262 |
+ |
263 |
+ emit q->loadingFinished(); |
264 |
+ } |
265 |
+ |
266 |
+- |
267 |
+ void KFileMetaDataProvider::Private::slotRatingChanged(unsigned int rating) |
268 |
+ { |
269 |
+ #ifndef KIO_NO_NEPOMUK |
270 |
+@@ -386,18 +407,27 @@ void KFileMetaDataProvider::setItems(const KFileItemList& items) |
271 |
+ } |
272 |
+ } |
273 |
+ |
274 |
+- // Cancel all threads that have not emitted a finished() signal. |
275 |
+- // The deleting of those threads is done in slotLoadingFinished(). |
276 |
+- foreach (KLoadFileMetaDataThread* thread, d->m_metaDataThreads) { |
277 |
+- thread->cancel(); |
278 |
++ // Create a new process that will provide the meta data for the items |
279 |
++ d->m_latestMetaDataProcess = new KProcess(); |
280 |
++ |
281 |
++ const QString fileMetaDataReaderExe = KStandardDirs::findExe(QLatin1String("kfilemetadatareader")); |
282 |
++ (*d->m_latestMetaDataProcess) << fileMetaDataReaderExe; |
283 |
++ |
284 |
++ foreach (const KUrl& url, urls) { |
285 |
++ (*d->m_latestMetaDataProcess) << url.url(); |
286 |
+ } |
287 |
+ |
288 |
+- // Create a new thread that will provide the meta data for the items |
289 |
+- d->m_latestMetaDataThread = new KLoadFileMetaDataThread(); |
290 |
+- connect(d->m_latestMetaDataThread, SIGNAL(finished(QThread*)), |
291 |
+- this, SLOT(slotLoadingFinished(QThread*))); |
292 |
+- d->m_latestMetaDataThread->load(urls); |
293 |
+- d->m_metaDataThreads.append(d->m_latestMetaDataThread); |
294 |
++ d->m_latestMetaDataProcess->setOutputChannelMode(KProcess::OnlyStdoutChannel); |
295 |
++ d->m_latestMetaDataProcess->setNextOpenMode(QIODevice::ReadOnly | QIODevice::Text); |
296 |
++ d->m_latestMetaDataProcess->start(); |
297 |
++ if (d->m_latestMetaDataProcess->waitForStarted()) { |
298 |
++ connect(d->m_latestMetaDataProcess, SIGNAL(finished(int, QProcess::ExitStatus)), |
299 |
++ this, SLOT(slotLoadingFinished(int, QProcess::ExitStatus))); |
300 |
++ d->m_metaDataProcesses.append(d->m_latestMetaDataProcess); |
301 |
++ } else { |
302 |
++ delete d->m_latestMetaDataProcess; |
303 |
++ d->m_latestMetaDataProcess = 0; |
304 |
++ } |
305 |
+ #endif |
306 |
+ } |
307 |
+ |
308 |
+diff --git a/kio/kfile/kfilemetadataprovider_p.h b/kio/kfile/kfilemetadataprovider_p.h |
309 |
+index 05ae848..ce6e259 100644 |
310 |
+--- a/kio/kfile/kfilemetadataprovider_p.h |
311 |
++++ b/kio/kfile/kfilemetadataprovider_p.h |
312 |
+@@ -33,6 +33,7 @@ |
313 |
+ #endif |
314 |
+ |
315 |
+ class KFileItemList; |
316 |
++class KProcess; |
317 |
+ class KUrl; |
318 |
+ class QWidget; |
319 |
+ |
320 |
+@@ -131,7 +132,7 @@ private: |
321 |
+ class Private; |
322 |
+ Private* const d; |
323 |
+ |
324 |
+- Q_PRIVATE_SLOT(d, void slotLoadingFinished(QThread* finishedThread)) |
325 |
++ Q_PRIVATE_SLOT(d, void slotLoadingFinished(int exitCode, QProcess::ExitStatus exitStatus)) |
326 |
+ Q_PRIVATE_SLOT(d, void slotRatingChanged(unsigned int rating)) |
327 |
+ Q_PRIVATE_SLOT(d, void slotTagsChanged(const QList<Nepomuk::Tag>& tags)) |
328 |
+ Q_PRIVATE_SLOT(d, void slotCommentChanged(const QString& comment)) |
329 |
+diff --git a/kio/kfile/kfilemetadatareader.cpp b/kio/kfile/kfilemetadatareader.cpp |
330 |
+new file mode 100644 |
331 |
+index 0000000..0609235 |
332 |
+--- /dev/null |
333 |
++++ b/kio/kfile/kfilemetadatareader.cpp |
334 |
+@@ -0,0 +1,174 @@ |
335 |
++/***************************************************************************** |
336 |
++ * Copyright (C) 2011 by Peter Penz <peter.penz@×××.at> * |
337 |
++ * * |
338 |
++ * This library is free software; you can redistribute it and/or * |
339 |
++ * modify it under the terms of the GNU Library General Public * |
340 |
++ * License as published by the Free Software Foundation; either * |
341 |
++ * version 2 of the License, or (at your option) any later version. * |
342 |
++ * * |
343 |
++ * This library is distributed in the hope that it will be useful, * |
344 |
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
345 |
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
346 |
++ * Library General Public License for more details. * |
347 |
++ * * |
348 |
++ * You should have received a copy of the GNU Library General Public License * |
349 |
++ * along with this library; see the file COPYING.LIB. If not, write to * |
350 |
++ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * |
351 |
++ * Boston, MA 02110-1301, USA. * |
352 |
++ *****************************************************************************/ |
353 |
++ |
354 |
++#include <iostream> |
355 |
++ |
356 |
++#include <kaboutdata.h> |
357 |
++#include <kcmdlineargs.h> |
358 |
++#include <kfilemetainfo.h> |
359 |
++#include <klocale.h> |
360 |
++ |
361 |
++#include <QtCore/QHash> |
362 |
++#include <QtCore/QString> |
363 |
++ |
364 |
++#define DISABLE_NEPOMUK_LEGACY |
365 |
++#include "config-nepomuk.h" |
366 |
++ |
367 |
++#include <nepomuk/query/filequery.h> |
368 |
++#include <nepomuk/query/comparisonterm.h> |
369 |
++#include <nepomuk/query/andterm.h> |
370 |
++#include <nepomuk/query/resourceterm.h> |
371 |
++#include <nepomuk/query/resourcetypeterm.h> |
372 |
++#include <nepomuk/query/optionalterm.h> |
373 |
++#include <nepomuk/utils/utils.h> |
374 |
++#include <nepomuk/property.h> |
375 |
++#include <nepomuk/tag.h> |
376 |
++#include <nepomuk/variant.h> |
377 |
++#include <nepomuk/resourcemanager.h> |
378 |
++ |
379 |
++using namespace std; |
380 |
++ |
381 |
++static void sendMetaData(const QHash<KUrl, Nepomuk::Variant>& data) |
382 |
++{ |
383 |
++ // Write the meta-data as sequence of the following properties: |
384 |
++ // 1. Metadata key |
385 |
++ // 2. Variant type |
386 |
++ // 3. Variant value |
387 |
++ QHashIterator<KUrl, Nepomuk::Variant> it(data); |
388 |
++ while (it.hasNext()) { |
389 |
++ it.next(); |
390 |
++ const QString key = it.key().url(); |
391 |
++ const Nepomuk::Variant& variant = it.value(); |
392 |
++ |
393 |
++ const QString variantType = QString::number(variant.type()); |
394 |
++ // TODO: serialize valuetypes like variant lists |
395 |
++ QString variantValue = variant.toString(); |
396 |
++ // QChar::Other_Control acts as separator between the output-values. |
397 |
++ // Assure that this character is not already part of a value: |
398 |
++ variantValue.remove(QChar::Other_Control); |
399 |
++ |
400 |
++ cout << key.toLocal8Bit().data() << endl; |
401 |
++ cout << variantType.toLocal8Bit().data() << endl; |
402 |
++ cout << variantValue.toLocal8Bit().data() << endl; |
403 |
++ } |
404 |
++} |
405 |
++ |
406 |
++static int readMetaData(const KCmdLineArgs* args) |
407 |
++{ |
408 |
++ KUrl::List urls; |
409 |
++ const int argsCount = args->count(); |
410 |
++ for (int i = 0; i < argsCount; ++i) { |
411 |
++ urls.append(KUrl(args->arg(i))); |
412 |
++ } |
413 |
++ |
414 |
++ unsigned int rating = 0; |
415 |
++ QString comment; |
416 |
++ QList<Nepomuk::Tag> tags; |
417 |
++ QHash<KUrl, Nepomuk::Variant> data; |
418 |
++ |
419 |
++ bool first = true; |
420 |
++ foreach (const KUrl& url, urls) { |
421 |
++ Nepomuk::Resource file(url); |
422 |
++ if (!file.isValid()) { |
423 |
++ continue; |
424 |
++ } |
425 |
++ |
426 |
++ if (!first && (rating != file.rating())) { |
427 |
++ rating = 0; // Reset rating |
428 |
++ } else if (first) { |
429 |
++ rating = file.rating(); |
430 |
++ } |
431 |
++ |
432 |
++ if (!first && (comment != file.description())) { |
433 |
++ comment.clear(); // Reset comment |
434 |
++ } else if (first) { |
435 |
++ comment = file.description(); |
436 |
++ } |
437 |
++ |
438 |
++ if (!first && (tags != file.tags())) { |
439 |
++ tags.clear(); // Reset tags |
440 |
++ } else if (first) { |
441 |
++ tags = file.tags(); |
442 |
++ } |
443 |
++ |
444 |
++ if (first && (urls.count() == 1)) { |
445 |
++ // Get cached meta data by checking the indexed files |
446 |
++ QHash<QUrl, Nepomuk::Variant> variants = file.properties(); |
447 |
++ QHash<QUrl, Nepomuk::Variant>::const_iterator it = variants.constBegin(); |
448 |
++ while (it != variants.constEnd()) { |
449 |
++ Nepomuk::Types::Property prop(it.key()); |
450 |
++ data.insert(prop.uri(), Nepomuk::Utils::formatPropertyValue(prop, it.value(), |
451 |
++ QList<Nepomuk::Resource>() << file, |
452 |
++ Nepomuk::Utils::WithKioLinks)); |
453 |
++ ++it; |
454 |
++ } |
455 |
++ |
456 |
++ if (variants.isEmpty()) { |
457 |
++ // The file has not been indexed, query the meta data |
458 |
++ // directly from the file. |
459 |
++ const QString path = urls.first().toLocalFile(); |
460 |
++ KFileMetaInfo metaInfo(path, QString(), KFileMetaInfo::Fastest); |
461 |
++ const QHash<QString, KFileMetaInfoItem> metaInfoItems = metaInfo.items(); |
462 |
++ foreach (const KFileMetaInfoItem& metaInfoItem, metaInfoItems) { |
463 |
++ const QString uriString = metaInfoItem.name(); |
464 |
++ const Nepomuk::Variant value(metaInfoItem.value()); |
465 |
++ data.insert(uriString, |
466 |
++ Nepomuk::Utils::formatPropertyValue(Nepomuk::Types::Property(), value)); |
467 |
++ } |
468 |
++ } |
469 |
++ } |
470 |
++ |
471 |
++ first = false; |
472 |
++ } |
473 |
++ |
474 |
++ if (Nepomuk::ResourceManager::instance()->initialized()) { |
475 |
++ data.insert(KUrl("kfileitem#rating"), rating); |
476 |
++ data.insert(KUrl("kfileitem#comment"), comment); |
477 |
++ |
478 |
++ QList<Nepomuk::Variant> tagVariants; |
479 |
++ foreach (const Nepomuk::Tag& tag, tags) { |
480 |
++ tagVariants.append(Nepomuk::Variant(tag)); |
481 |
++ } |
482 |
++ data.insert(KUrl("kfileitem#tags"), tagVariants); |
483 |
++ } |
484 |
++ |
485 |
++ sendMetaData(data); |
486 |
++ return 0; |
487 |
++} |
488 |
++ |
489 |
++int main(int argc, char *argv[]) |
490 |
++{ |
491 |
++ KAboutData aboutData("kfilemetadatareader", 0, ki18n("KFileMetaDataReader"), |
492 |
++ "1.0", |
493 |
++ ki18n("KFileMetaDataReader can be used to read metadata from a file"), |
494 |
++ KAboutData::License_GPL, |
495 |
++ ki18n("(C) 2011, Peter Penz")); |
496 |
++ aboutData.addAuthor(ki18n("Peter Penz"), ki18n("Current maintainer"), "peter.penz19@×××××.com"); |
497 |
++ |
498 |
++ KCmdLineArgs::init(argc, argv, &aboutData); |
499 |
++ |
500 |
++ KCmdLineOptions options; |
501 |
++ options.add("+[arg]", ki18n("List of URLs where the meta-data should be read from")); |
502 |
++ |
503 |
++ KCmdLineArgs::addCmdLineOptions(options); |
504 |
++ const KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
505 |
++ |
506 |
++ return readMetaData(args); |
507 |
++} |
508 |
++ |
509 |
+diff --git a/kio/kfile/kfilemetadatawidget.cpp b/kio/kfile/kfilemetadatawidget.cpp |
510 |
+index dca3a12..532d884 100644 |
511 |
+--- a/kio/kfile/kfilemetadatawidget.cpp |
512 |
++++ b/kio/kfile/kfilemetadatawidget.cpp |
513 |
+@@ -41,9 +41,7 @@ |
514 |
+ #include <property.h> |
515 |
+ #include <tag.h> |
516 |
+ |
517 |
+- #include <QMutex> |
518 |
+ #include <QSpacerItem> |
519 |
+- #include <QThread> |
520 |
+ #endif |
521 |
+ |
522 |
+ class KFileMetaDataWidget::Private |
523 |
+diff --git a/kio/kfile/kloadfilemetadatathread.cpp b/kio/kfile/kloadfilemetadatathread.cpp |
524 |
+deleted file mode 100644 |
525 |
+index 55d2c37..0000000 |
526 |
+--- a/kio/kfile/kloadfilemetadatathread.cpp |
527 |
++++ /dev/null |
528 |
+@@ -1,178 +0,0 @@ |
529 |
+-/***************************************************************************** |
530 |
+- * Copyright (C) 2009-2010 by Peter Penz <peter.penz@×××.at> * |
531 |
+- * Copyright (C) 2009-2010 by Sebastian Trueg <trueg@×××.org> * |
532 |
+- * * |
533 |
+- * This library is free software; you can redistribute it and/or * |
534 |
+- * modify it under the terms of the GNU Library General Public * |
535 |
+- * License as published by the Free Software Foundation; either * |
536 |
+- * version 2 of the License, or (at your option) any later version. * |
537 |
+- * * |
538 |
+- * This library is distributed in the hope that it will be useful, * |
539 |
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
540 |
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
541 |
+- * Library General Public License for more details. * |
542 |
+- * * |
543 |
+- * You should have received a copy of the GNU Library General Public License * |
544 |
+- * along with this library; see the file COPYING.LIB. If not, write to * |
545 |
+- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * |
546 |
+- * Boston, MA 02110-1301, USA. * |
547 |
+- *****************************************************************************/ |
548 |
+- |
549 |
+-#include "kloadfilemetadatathread_p.h" |
550 |
+- |
551 |
+-#include <kfilemetainfo.h> |
552 |
+-#include <kfilemetainfoitem.h> |
553 |
+-#include <kglobal.h> |
554 |
+-#include <klocale.h> |
555 |
+-#include "kfilemetadataprovider_p.h" |
556 |
+-#include <kprotocolinfo.h> |
557 |
+- |
558 |
+-#include "resource.h" |
559 |
+-#include "thing.h" |
560 |
+-#include "variant.h" |
561 |
+-#include "resourcemanager.h" |
562 |
+- |
563 |
+-#include "config-nepomuk.h" |
564 |
+- |
565 |
+-#include "query/filequery.h" |
566 |
+-#include "query/comparisonterm.h" |
567 |
+-#include "query/andterm.h" |
568 |
+-#include "query/resourceterm.h" |
569 |
+-#include "query/resourcetypeterm.h" |
570 |
+-#include "query/optionalterm.h" |
571 |
+-#include "utils/utils.h" |
572 |
+- |
573 |
+-#include <Soprano/Model> |
574 |
+-#include <Soprano/QueryResultIterator> |
575 |
+-#include <Soprano/NodeIterator> |
576 |
+- |
577 |
+-#include <QMutexLocker> |
578 |
+- |
579 |
+-KLoadFileMetaDataThread::KLoadFileMetaDataThread() |
580 |
+- : m_canceled(false) |
581 |
+-{ |
582 |
+- connect(this, SIGNAL(finished()), this, SLOT(slotLoadingFinished())); |
583 |
+-} |
584 |
+- |
585 |
+-KLoadFileMetaDataThread::~KLoadFileMetaDataThread() |
586 |
+-{ |
587 |
+-} |
588 |
+- |
589 |
+-void KLoadFileMetaDataThread::load(const KUrl::List& urls) |
590 |
+-{ |
591 |
+- QMutexLocker locker(&m_mutex); |
592 |
+- m_urls = urls; |
593 |
+- m_canceled = false; |
594 |
+- start(); |
595 |
+-} |
596 |
+- |
597 |
+-QHash<KUrl, Nepomuk::Variant> KLoadFileMetaDataThread::data() const |
598 |
+-{ |
599 |
+- QMutexLocker locker(&m_mutex); |
600 |
+- return m_data; |
601 |
+-} |
602 |
+- |
603 |
+-void KLoadFileMetaDataThread::cancel() |
604 |
+-{ |
605 |
+- // Setting m_canceled to true will cancel KLoadFileMetaDataThread::run() |
606 |
+- // as soon as run() gets the chance to check m_cancel. |
607 |
+- m_canceled = true; |
608 |
+-} |
609 |
+- |
610 |
+-void KLoadFileMetaDataThread::run() |
611 |
+-{ |
612 |
+- QMutexLocker locker(&m_mutex); |
613 |
+- const KUrl::List urls = m_urls; |
614 |
+- locker.unlock(); // no shared member is accessed until locker.relock() |
615 |
+- |
616 |
+- unsigned int rating = 0; |
617 |
+- QString comment; |
618 |
+- QList<Nepomuk::Tag> tags; |
619 |
+- QHash<KUrl, Nepomuk::Variant> data; |
620 |
+- |
621 |
+- bool first = true; |
622 |
+- foreach (const KUrl& url, urls) { |
623 |
+- if (m_canceled) { |
624 |
+- return; |
625 |
+- } |
626 |
+- |
627 |
+- Nepomuk::Resource file(url); |
628 |
+- if (!file.isValid()) { |
629 |
+- continue; |
630 |
+- } |
631 |
+- |
632 |
+- if (!first && (rating != file.rating())) { |
633 |
+- rating = 0; // reset rating |
634 |
+- } else if (first) { |
635 |
+- rating = file.rating(); |
636 |
+- } |
637 |
+- |
638 |
+- if (!first && (comment != file.description())) { |
639 |
+- comment.clear(); // reset comment |
640 |
+- } else if (first) { |
641 |
+- comment = file.description(); |
642 |
+- } |
643 |
+- |
644 |
+- if (!first && (tags != file.tags())) { |
645 |
+- tags.clear(); // reset tags |
646 |
+- } else if (first) { |
647 |
+- tags = file.tags(); |
648 |
+- } |
649 |
+- |
650 |
+- if (first && (urls.count() == 1)) { |
651 |
+- // get cached meta data by checking the indexed files |
652 |
+- QHash<QUrl, Nepomuk::Variant> variants = file.properties(); |
653 |
+- QHash<QUrl, Nepomuk::Variant>::const_iterator it = variants.constBegin(); |
654 |
+- while (it != variants.constEnd()) { |
655 |
+- Nepomuk::Types::Property prop(it.key()); |
656 |
+- data.insert(prop.uri(), Nepomuk::Utils::formatPropertyValue(prop, it.value(), QList<Nepomuk::Resource>() << file, Nepomuk::Utils::WithKioLinks)); |
657 |
+- ++it; |
658 |
+- } |
659 |
+- |
660 |
+- if (variants.isEmpty()) { |
661 |
+- // The file has not been indexed, query the meta data |
662 |
+- // directly from the file |
663 |
+- |
664 |
+- // TODO: Some Strigi analyzers (used in KFileMetaInfo) are not reentrant. |
665 |
+- // As workaround the access is protected by a mutex here. To reproduce |
666 |
+- // the issue run kfilemetainfotest with helgrind. |
667 |
+- static QMutex metaInfoMutex; |
668 |
+- metaInfoMutex.lock(); |
669 |
+- |
670 |
+- const QString path = urls.first().toLocalFile(); |
671 |
+- KFileMetaInfo metaInfo(path, QString(), KFileMetaInfo::Fastest); |
672 |
+- const QHash<QString, KFileMetaInfoItem> metaInfoItems = metaInfo.items(); |
673 |
+- foreach (const KFileMetaInfoItem& metaInfoItem, metaInfoItems) { |
674 |
+- const QString uriString = metaInfoItem.name(); |
675 |
+- const Nepomuk::Variant value(metaInfoItem.value()); |
676 |
+- data.insert(uriString, Nepomuk::Utils::formatPropertyValue(Nepomuk::Types::Property(), value)); |
677 |
+- } |
678 |
+- |
679 |
+- metaInfoMutex.unlock(); |
680 |
+- } |
681 |
+- } |
682 |
+- |
683 |
+- first = false; |
684 |
+- } |
685 |
+- |
686 |
+- if (Nepomuk::ResourceManager::instance()->initialized()) { |
687 |
+- data.insert(KUrl("kfileitem#rating"), rating); |
688 |
+- data.insert(KUrl("kfileitem#comment"), comment); |
689 |
+- |
690 |
+- QList<Nepomuk::Variant> tagVariants; |
691 |
+- foreach (const Nepomuk::Tag& tag, tags) { |
692 |
+- tagVariants.append(Nepomuk::Variant(tag)); |
693 |
+- } |
694 |
+- data.insert(KUrl("kfileitem#tags"), tagVariants); |
695 |
+- } |
696 |
+- |
697 |
+- locker.relock(); |
698 |
+- m_data = data; |
699 |
+-} |
700 |
+- |
701 |
+-void KLoadFileMetaDataThread::slotLoadingFinished() |
702 |
+-{ |
703 |
+- emit finished(this); |
704 |
+-} |
705 |
+- |
706 |
+-#include "kloadfilemetadatathread_p.moc" |
707 |
+diff --git a/kio/kfile/kloadfilemetadatathread_p.h b/kio/kfile/kloadfilemetadatathread_p.h |
708 |
+deleted file mode 100644 |
709 |
+index 006e3a0..0000000 |
710 |
+--- a/kio/kfile/kloadfilemetadatathread_p.h |
711 |
++++ /dev/null |
712 |
+@@ -1,96 +0,0 @@ |
713 |
+-/***************************************************************************** |
714 |
+- * Copyright (C) 2009-2010 by Peter Penz <peter.penz@×××.at> * |
715 |
+- * * |
716 |
+- * This library is free software; you can redistribute it and/or * |
717 |
+- * modify it under the terms of the GNU Library General Public * |
718 |
+- * License as published by the Free Software Foundation; either * |
719 |
+- * version 2 of the License, or (at your option) any later version. * |
720 |
+- * * |
721 |
+- * This library is distributed in the hope that it will be useful, * |
722 |
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
723 |
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
724 |
+- * Library General Public License for more details. * |
725 |
+- * * |
726 |
+- * You should have received a copy of the GNU Library General Public License * |
727 |
+- * along with this library; see the file COPYING.LIB. If not, write to * |
728 |
+- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * |
729 |
+- * Boston, MA 02110-1301, USA. * |
730 |
+- *****************************************************************************/ |
731 |
+- |
732 |
+-#ifndef KLOADFILEMETADATATHREAD_H |
733 |
+-#define KLOADFILEMETADATATHREAD_H |
734 |
+- |
735 |
+-#define DISABLE_NEPOMUK_LEGACY |
736 |
+-#include <property.h> |
737 |
+-#include <tag.h> |
738 |
+-#include <variant.h> |
739 |
+- |
740 |
+-#include <kurl.h> |
741 |
+-#include <QList> |
742 |
+-#include <QMutex> |
743 |
+-#include <QThread> |
744 |
+- |
745 |
+-/** |
746 |
+- * Loads the meta data of files that are |
747 |
+- * required by the widget KMetaDataWidget. |
748 |
+- * |
749 |
+- * Is used in KMetaDataModel. |
750 |
+- */ |
751 |
+-class KLoadFileMetaDataThread : public QThread |
752 |
+-{ |
753 |
+- Q_OBJECT |
754 |
+- |
755 |
+-public: |
756 |
+- KLoadFileMetaDataThread(); |
757 |
+- virtual ~KLoadFileMetaDataThread(); |
758 |
+- |
759 |
+- /** |
760 |
+- * Starts the thread and loads the meta data for |
761 |
+- * the files given by \p urls. After receiving |
762 |
+- * the signal finished(), the method KLoadFileMetaDataThread::data() |
763 |
+- * provides the loaded meta data. |
764 |
+- */ |
765 |
+- void load(const KUrl::List& urls); |
766 |
+- |
767 |
+- /** |
768 |
+- * Returns the meta data for the URLs given |
769 |
+- * by KLoadFileMetaDataThread::load(). The method only provides |
770 |
+- * valid results after the signal finished() has been |
771 |
+- * emitted. |
772 |
+- */ |
773 |
+- QHash<KUrl, Nepomuk::Variant> data() const; |
774 |
+- |
775 |
+- /** |
776 |
+- * Tells the thread that it should cancel as soon |
777 |
+- * as possible. It is undefined when the thread |
778 |
+- * gets cancelled. The signal finished() will emitted |
779 |
+- * after the cancelling has been done.mergedIt |
780 |
+- */ |
781 |
+- void cancel(); |
782 |
+- |
783 |
+- /** @see QThread::run() */ |
784 |
+- virtual void run(); |
785 |
+- |
786 |
+-Q_SIGNALS: |
787 |
+- /** |
788 |
+- * Is emitted if the thread has finished the loading. KMetaDataModel |
789 |
+- * requires the information which thread has been finished, hence |
790 |
+- * the thread is passed as parameter (using QObject::sender() would |
791 |
+- * be an alternative, but it is less understandable). |
792 |
+- */ |
793 |
+- void finished(QThread* thread); |
794 |
+- |
795 |
+-private slots: |
796 |
+- /** |
797 |
+- * Emits the signal finished() including the thread as parameter. |
798 |
+- */ |
799 |
+- void slotLoadingFinished(); |
800 |
+- |
801 |
+-private: |
802 |
+- mutable QMutex m_mutex; |
803 |
+- QHash<KUrl, Nepomuk::Variant> m_data; |
804 |
+- KUrl::List m_urls; |
805 |
+- |
806 |
+- volatile bool m_canceled; |
807 |
+-}; |
808 |
+-#endif |
809 |
|
810 |
diff --git a/kde-base/kdelibs/kdelibs-4.6.2.ebuild b/kde-base/kdelibs/kdelibs-4.6.2.ebuild |
811 |
index b28049b..4b2d0e7 100644 |
812 |
--- a/kde-base/kdelibs/kdelibs-4.6.2.ebuild |
813 |
+++ b/kde-base/kdelibs/kdelibs-4.6.2.ebuild |
814 |
@@ -136,6 +136,7 @@ PATCHES=( |
815 |
"${FILESDIR}/${PN}-4.5.90-mimetypes.patch" |
816 |
"${FILESDIR}/${PN}-4.4.90-xslt.patch" |
817 |
"${FILESDIR}/${PN}-4.6.0-kateacc.patch" |
818 |
+ "${FILESDIR}/${PN}-4.6.2-safestrigi.patch" |
819 |
) |
820 |
|
821 |
src_prepare() { |
822 |
|
823 |
diff --git a/kde-base/kdelibs/kdelibs-4.6.9999.ebuild b/kde-base/kdelibs/kdelibs-4.6.9999.ebuild |
824 |
index 6d76d50..61b0f5f 100644 |
825 |
--- a/kde-base/kdelibs/kdelibs-4.6.9999.ebuild |
826 |
+++ b/kde-base/kdelibs/kdelibs-4.6.9999.ebuild |
827 |
@@ -136,6 +136,7 @@ PATCHES=( |
828 |
"${FILESDIR}/${PN}-4.5.90-mimetypes.patch" |
829 |
"${FILESDIR}/${PN}-4.4.90-xslt.patch" |
830 |
"${FILESDIR}/${PN}-4.6.0-kateacc.patch" |
831 |
+ "${FILESDIR}/${PN}-4.6.2-safestrigi.patch" |
832 |
) |
833 |
|
834 |
src_prepare() { |