[Kde-imaging] [kipi-plugins] common/libkipiplugins: New simple KExiv2 based interface class to manage KIPI host application metadada settings and Read/Lock files mechanism introduced
Gilles Caulier
caulier.gilles at gmail.com
Mon Feb 20 11:36:02 UTC 2012
Git commit a62d04bbed16d50db9e560f0c93aee437ba0f74c by Gilles Caulier.
Committed on 20/02/2012 at 10:55.
Pushed by cgilles into branch 'master'.
New simple KExiv2 based interface class to manage KIPI host application metadada settings and Read/Lock files mechanism introduced
with list libkipi API by Marcel, to prevent concurents access to files by kipi-plugins and host application at the same time, through image metadata.
This class must be used everywhere in plugins instead KExiv2 (not yet done).
CCMAIL: kde-imaging at kde.org
CCMAIL: marcel.wiesweg at gmx.de
M +1 -0 common/libkipiplugins/CMakeLists.txt
A +79 -0 common/libkipiplugins/tools/kpmetadata.cpp [License: GPL (v2+)]
A +84 -0 common/libkipiplugins/tools/kpmetadata.h [License: GPL (v2+)]
http://commits.kde.org/kipi-plugins/a62d04bbed16d50db9e560f0c93aee437ba0f74c
diff --git a/common/libkipiplugins/CMakeLists.txt b/common/libkipiplugins/CMakeLists.txt
index 0e0acb7..0c3a9b9 100644
--- a/common/libkipiplugins/CMakeLists.txt
+++ b/common/libkipiplugins/CMakeLists.txt
@@ -6,6 +6,7 @@ SET(kipiplugins_LIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpaboutdata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpwriteimage.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpimageinfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kphostsettings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/tools/kpmetadata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpmetasettings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpwritehelp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tools/kpversion.cpp
diff --git a/common/libkipiplugins/tools/kpmetadata.cpp b/common/libkipiplugins/tools/kpmetadata.cpp
new file mode 100644
index 0000000..3964997
--- /dev/null
+++ b/common/libkipiplugins/tools/kpmetadata.cpp
@@ -0,0 +1,79 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2012-02-20
+ * Description : Metadata interface for kipi-plugins.
+ *
+ * Copyright (C) 2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ * Copyright (C) 2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#include "kpmetadata.h"
+
+// LibKipi includes
+
+#include <libkipi/version.h>
+#include <libkipi/interface.h>
+
+using namespace KIPI;
+
+namespace KIPIPlugins
+{
+
+KPMetadata::KPMetadata(const QString& filePath, const KPMetaSettings& settings)
+ : KExiv2()
+{
+ setSettings(settings);
+ load(filePath);
+}
+
+void KPMetadata::setSettings(const KPMetaSettings& settings)
+{
+ setUseXMPSidecar4Reading(settings.useXMPSidecar4Reading);
+ setWriteRawFiles(settings.writeRawFiles);
+ setMetadataWritingMode(settings.metadataWritingMode);
+ setUpdateFileTimeStamp(settings.updateFileTimeStamp);
+}
+
+bool KPMetadata::load(const QString& filePath) const
+{
+#if KIPI_VERSION >= 0x010500
+ //FileReadLocker(KUrl(filePath));
+#endif
+
+ return KExiv2::load(filePath);
+}
+
+bool KPMetadata::save(const QString& filePath) const
+{
+#if KIPI_VERSION >= 0x010500
+ //FileWriteLocker(KUrl(filePath));
+#endif
+
+ return KExiv2::save(filePath);
+}
+
+bool KPMetadata::applyChanges() const
+{
+#if KIPI_VERSION >= 0x010500
+ //FileWriteLocker(KUrl(getFilePath()));
+#endif
+
+ return KExiv2::applyChanges();
+}
+
+} // namespace KIPIPlugins
diff --git a/common/libkipiplugins/tools/kpmetadata.h b/common/libkipiplugins/tools/kpmetadata.h
new file mode 100644
index 0000000..786edee
--- /dev/null
+++ b/common/libkipiplugins/tools/kpmetadata.h
@@ -0,0 +1,84 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2012-02-20
+ * Description : Metadata interface for kipi-plugins.
+ *
+ * Copyright (C) 2012 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ * Copyright (C) 2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef KPMETADATA_H
+#define KPMETADATA_H
+
+// LibKExiv2 includes
+
+#include <libkexiv2/kexiv2.h>
+
+// Local includes
+
+#include "kpmetasettings.h"
+#include "kipiplugins_export.h"
+
+using namespace KExiv2Iface;
+
+namespace KIPIPlugins
+{
+
+/** This class must be used in plugins instead KExiv2 metadata interface to handle file lock mechanism
+ * with KIPI host application to prevent concurent operations on file during load and save operations.
+ * This class is also able to use KIPI host application metadata settings through KPMetaSettings container.
+ * This settings must be taken from KIPI host application using KPHostSettings interface.
+ */
+class KIPIPLUGINS_EXPORT KPMetadata : public KExiv2
+{
+
+public:
+
+ /** Constructor to load metadata from file, using metadata settings from KIPI host application.
+ */
+ KPMetadata(const QString& filePath, const KPMetaSettings& settings);
+
+ /** Apply metadata settings from KIPI host application to this interface. To use before load and save operations.
+ */
+ void setSettings(const KPMetaSettings& settings);
+
+ /** Load metadata operation from a file.
+ * Re-implemented from libKexiv2 to use lock mechanism with KIPI host application through KIPI::Interface.
+ */
+ bool load(const QString& filePath) const;
+
+ /** Save metadata operation to a file.
+ * Re-implemented from libKexiv2 to use lock mechanism with KIPI host application through KIPI::Interface.
+ */
+ bool save(const QString& filePath) const;
+
+ /** Perform save metadata operation to current loaded file.
+ * Re-implemented from libKexiv2 to use lock mechanism with KIPI host application through KIPI::Interface.
+ */
+ bool applyChanges() const;
+
+private:
+
+
+ KPMetadata() {}; // Disable
+ ~KPMetadata() {}; // Disable
+};
+
+} // namespace KIPIPlugins
+
+#endif /* KPMETADATA_H */
More information about the Kde-imaging
mailing list