[niepce] rust+engine: move more definitions to Rust
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] rust+engine: move more definitions to Rust
- Date: Thu, 28 Sep 2017 13:41:18 +0000 (UTC)
commit 82eb778ff8b270b0bcd19633f6fe2fe31e7f0b58
Author: Hubert Figuière <hub figuiere net>
Date: Wed Sep 27 22:22:42 2017 -0400
rust+engine: move more definitions to Rust
- use a bleeding edge cbindgen to generate the enums
- various type renamed
- work around some bugs
Cargo.toml | 2 +-
build.rs | 2 -
src/engine/db/bindings.hpp | 1 -
src/engine/db/filebundle.cpp | 5 +-
src/engine/db/filebundle.hpp | 10 ++--
src/engine/db/filebundle.rs | 22 ++++----
src/engine/db/keyword.cpp | 7 +--
src/engine/db/keyword.hpp | 4 -
src/engine/db/keyword.rs | 12 ++--
src/engine/db/libfile.cpp | 34 ++++-------
src/engine/db/libfile.hpp | 31 +---------
src/engine/db/libfile.rs | 74 +++++++++++++----------
src/engine/db/libfolder.hpp | 6 --
src/engine/db/libmetadata.hpp | 1 -
src/engine/db/library.cpp | 8 +--
src/engine/db/library.hpp | 6 +-
src/engine/db/library.rs | 14 +++-
src/engine/importer/cameraimporter.cpp | 2 +-
src/engine/importer/directoryimporter.cpp | 2 +-
src/engine/importer/iimporter.hpp | 4 +-
src/engine/library/commands.rs | 38 ++++++------
src/engine/library/notification.cpp | 1 -
src/engine/library/notification.hpp | 36 +++---------
src/engine/library/notification.rs | 6 +-
src/libraryclient/clientimpl.cpp | 43 +++++++-------
src/libraryclient/clientimpl.hpp | 6 +-
src/libraryclient/libraryclient.cpp | 6 +-
src/libraryclient/libraryclient.hpp | 4 +-
src/niepce/modules/darkroom/darkroommodule.cpp | 4 +-
src/niepce/modules/map/mapmodule.cpp | 4 +-
src/niepce/ui/gridviewmodule.cpp | 6 +-
src/niepce/ui/imageliststore.cpp | 16 +++---
src/niepce/ui/librarycellrenderer.cpp | 8 +-
src/niepce/ui/niepcewindow.cpp | 16 +++--
src/niepce/ui/workspacecontroller.cpp | 15 +++--
src/rust_bindings.hpp | 21 ++++++-
36 files changed, 217 insertions(+), 260 deletions(-)
---
diff --git a/Cargo.toml b/Cargo.toml
index f1c642f..0e22de6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,7 +15,7 @@ gio = "0.2.0"
[build-dependencies]
bindgen = "0.30.0"
-cbindgen = "0.1.23"
+cbindgen = { version = "0.1.23", git = "https://github.com/eqrion/cbindgen.git" }
pkg-config = "0.3.9"
[lib]
diff --git a/build.rs b/build.rs
index b182deb..173cd94 100644
--- a/build.rs
+++ b/build.rs
@@ -20,10 +20,8 @@ fn main() {
// The input header we would like to generate
// bindings for.
.whitelisted_type("eng::NiepceProperties")
- .whitelisted_type("eng::LibFileType")
.whitelisted_type("eng::QueriedContent")
.opaque_type("eng::QueriedContent")
- .whitelisted_type("eng::LibraryManaged")
.whitelisted_type("fwk::FileList")
.whitelisted_type("eng::IndexToXmp")
.whitelisted_function("eng::property_index_to_xmp")
diff --git a/src/engine/db/bindings.hpp b/src/engine/db/bindings.hpp
index 66afae8..b27d1ca 100644
--- a/src/engine/db/bindings.hpp
+++ b/src/engine/db/bindings.hpp
@@ -3,6 +3,5 @@
#include "properties-enum.hpp"
#include "engine/db/libmetadata.hpp"
-#include "engine/db/library.hpp"
#include "engine/library/notification.hpp"
#include "fwk/utils/files.hpp"
diff --git a/src/engine/db/filebundle.cpp b/src/engine/db/filebundle.cpp
index 64ec299..4665d4c 100644
--- a/src/engine/db/filebundle.cpp
+++ b/src/engine/db/filebundle.cpp
@@ -24,13 +24,10 @@
#include "fwk/utils/pathutils.hpp"
#include "fwk/toolkit/mimetype.hpp"
-extern "C" eng::FileBundle* engine_db_filebundle_new();
-extern "C" void engine_db_filebundle_delete(eng::FileBundle*);
-
namespace eng {
FileBundlePtr filebundle_new() {
- return FileBundlePtr(engine_db_filebundle_new(), &engine_db_filebundle_delete);
+ return FileBundlePtr(ffi::engine_db_filebundle_new(), &ffi::engine_db_filebundle_delete);
}
FileBundleListPtr
diff --git a/src/engine/db/filebundle.hpp b/src/engine/db/filebundle.hpp
index 8785665..f9e9b24 100644
--- a/src/engine/db/filebundle.hpp
+++ b/src/engine/db/filebundle.hpp
@@ -24,9 +24,14 @@
#include "fwk/utils/files.hpp"
+#include "rust_bindings.hpp"
+
namespace eng {
+#if RUST_BINDGEN
class FileBundle;
+#endif
+
typedef std::shared_ptr<FileBundle> FileBundlePtr;
typedef std::list<FileBundlePtr> FileBundleList;
typedef std::shared_ptr<FileBundleList> FileBundleListPtr;
@@ -36,11 +41,6 @@ FileBundleListPtr filebundle_filter_bundles(const fwk::FileList::Ptr & files);
FileBundlePtr filebundle_new();
}
-extern "C" const char* engine_db_filebundle_sidecar(const eng::FileBundle*);
-extern "C" const char* engine_db_filebundle_main(const eng::FileBundle*);
-extern "C" const char* engine_db_filebundle_jpeg(const eng::FileBundle*);
-extern "C" bool engine_db_filebundle_add(eng::FileBundle*, const char*);
-
/*
Local Variables:
mode:c++
diff --git a/src/engine/db/filebundle.rs b/src/engine/db/filebundle.rs
index 35f868d..fee99dc 100644
--- a/src/engine/db/filebundle.rs
+++ b/src/engine/db/filebundle.rs
@@ -148,24 +148,24 @@ pub extern fn engine_db_filebundle_delete(fb: *mut FileBundle) {
}
#[no_mangle]
-pub extern fn engine_db_filebundle_sidecar(this: &mut FileBundle) -> *const c_char {
- this.xmp_sidecar_c = CString::new(this.sidecar()).unwrap();
- this.xmp_sidecar_c.as_ptr()
+pub extern fn engine_db_filebundle_sidecar(obj: &mut FileBundle) -> *const c_char {
+ obj.xmp_sidecar_c = CString::new(obj.sidecar()).unwrap();
+ obj.xmp_sidecar_c.as_ptr()
}
#[no_mangle]
-pub extern fn engine_db_filebundle_main(this: &mut FileBundle) -> *const c_char {
- this.main_c = CString::new(this.main()).unwrap();
- this.main_c.as_ptr()
+pub extern fn engine_db_filebundle_main(obj: &mut FileBundle) -> *const c_char {
+ obj.main_c = CString::new(obj.main()).unwrap();
+ obj.main_c.as_ptr()
}
#[no_mangle]
-pub extern fn engine_db_filebundle_jpeg(this: &mut FileBundle) -> *const c_char {
- this.jpeg_c = CString::new(this.jpeg()).unwrap();
- this.jpeg_c.as_ptr()
+pub extern fn engine_db_filebundle_jpeg(obj: &mut FileBundle) -> *const c_char {
+ obj.jpeg_c = CString::new(obj.jpeg()).unwrap();
+ obj.jpeg_c.as_ptr()
}
#[no_mangle]
-pub extern fn engine_db_filebundle_add(this: &mut FileBundle, f: *const c_char) -> c_char {
- this.add(&*unsafe { CStr::from_ptr(f) }.to_string_lossy()) as c_char
+pub extern fn engine_db_filebundle_add(obj: &mut FileBundle, f: *const c_char) -> c_char {
+ obj.add(&*unsafe { CStr::from_ptr(f) }.to_string_lossy()) as c_char
}
diff --git a/src/engine/db/keyword.cpp b/src/engine/db/keyword.cpp
index 4d500ca..4e0c490 100644
--- a/src/engine/db/keyword.cpp
+++ b/src/engine/db/keyword.cpp
@@ -20,17 +20,14 @@
#include "keyword.hpp"
-extern "C" eng::Keyword* engine_db_keyword_new(eng::library_id_t id, const char* keyword);
-extern "C" void engine_db_keyword_delete(eng::Keyword*);
-
namespace eng {
KeywordPtr keyword_new(eng::library_id_t id, const char* keyword) {
- return keyword_wrap(engine_db_keyword_new(id, keyword));
+ return keyword_wrap(ffi::engine_db_keyword_new(id, keyword));
}
KeywordPtr keyword_wrap(eng::Keyword* kw) {
- return KeywordPtr(kw, &engine_db_keyword_delete);
+ return KeywordPtr(kw, &ffi::engine_db_keyword_delete);
}
}
diff --git a/src/engine/db/keyword.hpp b/src/engine/db/keyword.hpp
index e077376..2a57f81 100644
--- a/src/engine/db/keyword.hpp
+++ b/src/engine/db/keyword.hpp
@@ -41,7 +41,3 @@ typedef std::shared_ptr<KeywordList> KeywordListPtr;
KeywordPtr keyword_new(eng::library_id_t id, const char* keyword);
KeywordPtr keyword_wrap(Keyword*);
}
-
-extern "C" eng::library_id_t engine_db_keyword_id(const eng::Keyword*);
-extern "C" const char* engine_db_keyword_keyword(const eng::Keyword*);
-
diff --git a/src/engine/db/keyword.rs b/src/engine/db/keyword.rs
index 2739a18..51f083d 100644
--- a/src/engine/db/keyword.rs
+++ b/src/engine/db/keyword.rs
@@ -27,14 +27,12 @@ use rusqlite;
pub struct Keyword {
id: LibraryId,
keyword: String,
- pub cstr: CString,
}
impl Keyword {
pub fn new(id: LibraryId, keyword: &str) -> Keyword {
Keyword {
id: id, keyword: String::from(keyword),
- cstr: CString::new("").unwrap()
}
}
@@ -69,14 +67,14 @@ pub extern fn engine_db_keyword_new(id: i64, keyword: *const c_char) -> *mut Key
}
#[no_mangle]
-pub extern fn engine_db_keyword_id(this: &Keyword) -> i64 {
- this.id() as i64
+pub extern fn engine_db_keyword_id(obj: &Keyword) -> i64 {
+ obj.id() as i64
}
#[no_mangle]
-pub extern fn engine_db_keyword_keyword(this: &mut Keyword) -> *const c_char {
- this.cstr = CString::new(this.keyword().clone()).unwrap();
- this.cstr.as_ptr()
+pub extern fn engine_db_keyword_keyword(obj: &Keyword) -> *mut c_char {
+ let cstr = CString::new(obj.keyword().clone()).unwrap();
+ cstr.into_raw()
}
#[no_mangle]
diff --git a/src/engine/db/libfile.cpp b/src/engine/db/libfile.cpp
index 206e585..2d88b61 100644
--- a/src/engine/db/libfile.cpp
+++ b/src/engine/db/libfile.cpp
@@ -22,14 +22,6 @@
#include "fwk/base/debug.hpp"
#include "properties.hpp"
-extern "C" {
-eng::LibFile *engine_db_libfile_new(eng::library_id_t id,
- eng::library_id_t folder_id,
- eng::library_id_t fs_file_id,
- const char *path, const char *name);
-void engine_db_libfile_delete(eng::LibFile *);
-}
-
namespace eng {
// some glue for rust
@@ -39,25 +31,23 @@ QueriedContent::QueriedContent(library_id_t _container)
{
}
-void QueriedContent::push(LibFile *f)
+void QueriedContent::push(void* f)
{
- files->push_back(eng::libfile_wrap(f));
+ files->push_back(eng::libfile_wrap(static_cast<LibFile*>(f)));
}
+
+LibFilePtr libfile_wrap(eng::LibFile *lf)
+{
+ return LibFilePtr(lf, &ffi::engine_db_libfile_delete);
}
-namespace eng {
LibFilePtr libfile_new(library_id_t id, library_id_t folder_id,
library_id_t fs_file_id, const char *path,
const char *name)
{
return libfile_wrap(
- engine_db_libfile_new(id, folder_id, fs_file_id, path, name));
-}
-
-LibFilePtr libfile_wrap(LibFile *lf)
-{
- return LibFilePtr(lf, &engine_db_libfile_delete);
+ ffi::engine_db_libfile_new(id, folder_id, fs_file_id, path, name));
}
/**
@@ -66,16 +56,16 @@ LibFilePtr libfile_wrap(LibFile *lf)
* @return the filetype
* @todo: add the JPEG+RAW file types.
*/
-LibFileType mimetype_to_filetype(fwk::MimeType mime)
+FileType mimetype_to_filetype(fwk::MimeType mime)
{
if (mime.isDigicamRaw()) {
- return LibFileType::RAW;
+ return FileType::RAW;
} else if (mime.isImage()) {
- return LibFileType::IMAGE;
+ return FileType::IMAGE;
} else if (mime.isMovie()) {
- return LibFileType::VIDEO;
+ return FileType::VIDEO;
} else {
- return LibFileType::UNKNOWN;
+ return FileType::UNKNOWN;
}
}
}
diff --git a/src/engine/db/libfile.hpp b/src/engine/db/libfile.hpp
index 17a47ff..33900f3 100644
--- a/src/engine/db/libfile.hpp
+++ b/src/engine/db/libfile.hpp
@@ -33,19 +33,13 @@
namespace eng {
-enum class LibFileType {
- UNKNOWN = 0,
- RAW = 1,
- RAW_JPEG = 2,
- IMAGE = 3,
- VIDEO = 4
-};
-
#if !RUST_BINDGEN
-LibFileType mimetype_to_filetype(fwk::MimeType mime);
+ffi::FileType mimetype_to_filetype(fwk::MimeType mime);
#endif
+#if RUST_BINDGEN
class LibFile;
+#endif
typedef std::shared_ptr<LibFile> LibFilePtr;
typedef std::weak_ptr<LibFile> LibFileWeakPtr;
typedef std::list<LibFilePtr> LibFileList;
@@ -56,25 +50,6 @@ LibFilePtr libfile_new(library_id_t, library_id_t, library_id_t, const char *,
LibFilePtr libfile_wrap(LibFile *);
}
-extern "C" {
-const char *engine_db_libfile_path(const eng::LibFile *);
-eng::library_id_t engine_db_libfile_id(const eng::LibFile *);
-eng::library_id_t engine_db_libfile_folderid(const eng::LibFile *);
-int32_t engine_db_libfile_orientation(const eng::LibFile *);
-int32_t engine_db_libfile_rating(const eng::LibFile *);
-int32_t engine_db_libfile_label(const eng::LibFile *);
-int32_t engine_db_libfile_flag(const eng::LibFile *);
-int32_t engine_db_libfile_property(const eng::LibFile *, fwk::PropertyIndex);
-eng::LibFileType engine_db_libfile_file_type(const eng::LibFile *);
-void engine_db_libfile_set_orientation(eng::LibFile *, int32_t);
-void engine_db_libfile_set_rating(eng::LibFile *, int32_t);
-void engine_db_libfile_set_label(eng::LibFile *, int32_t);
-void engine_db_libfile_set_flag(eng::LibFile *, int32_t);
-void engine_db_libfile_set_property(const eng::LibFile *, fwk::PropertyIndex,
- int32_t);
-void engine_db_libfile_set_file_type(eng::LibFile *, eng::LibFileType);
-}
-
/*
Local Variables:
mode:c++
diff --git a/src/engine/db/libfile.rs b/src/engine/db/libfile.rs
index e1c7507..34ebbc0 100644
--- a/src/engine/db/libfile.rs
+++ b/src/engine/db/libfile.rs
@@ -29,9 +29,19 @@ use super::LibraryId;
use super::fsfile::FsFile;
use fwk::base::PropertyIndex;
use root::eng::NiepceProperties as Np;
-pub use root::eng::LibFileType as FileType;
use fwk;
+#[repr(i32)]
+#[allow(non_camel_case_types)]
+#[derive(Debug, Clone, PartialEq)]
+pub enum FileType {
+ UNKNOWN = 0,
+ RAW = 1,
+ RAW_JPEG = 2,
+ IMAGE = 3,
+ VIDEO = 4,
+}
+
impl From<i32> for FileType {
fn from(t: i32) -> Self {
match t {
@@ -239,77 +249,77 @@ pub extern fn engine_db_libfile_delete(lf: *mut LibFile) {
}
#[no_mangle]
-pub extern fn engine_db_libfile_path(this: &mut LibFile) -> *const c_char {
- this.cstr = CString::new(this.path().to_str().unwrap_or("")).unwrap();
- this.cstr.as_ptr()
+pub extern fn engine_db_libfile_path(obj: &mut LibFile) -> *const c_char {
+ obj.cstr = CString::new(obj.path().to_str().unwrap_or("")).unwrap();
+ obj.cstr.as_ptr()
}
#[no_mangle]
-pub extern fn engine_db_libfile_id(this: &LibFile) -> LibraryId {
- this.id()
+pub extern fn engine_db_libfile_id(obj: &LibFile) -> LibraryId {
+ obj.id()
}
#[no_mangle]
-pub extern fn engine_db_libfile_folderid(this: &LibFile) -> LibraryId {
- this.folder_id()
+pub extern fn engine_db_libfile_folderid(obj: &LibFile) -> LibraryId {
+ obj.folder_id()
}
#[no_mangle]
-pub extern fn engine_db_libfile_orientation(this: &LibFile) -> i32 {
- this.orientation()
+pub extern fn engine_db_libfile_orientation(obj: &LibFile) -> i32 {
+ obj.orientation()
}
#[no_mangle]
-pub extern fn engine_db_libfile_rating(this: &LibFile) -> i32 {
- this.rating()
+pub extern fn engine_db_libfile_rating(obj: &LibFile) -> i32 {
+ obj.rating()
}
#[no_mangle]
-pub extern fn engine_db_libfile_label(this: &LibFile) -> i32 {
- this.label()
+pub extern fn engine_db_libfile_label(obj: &LibFile) -> i32 {
+ obj.label()
}
#[no_mangle]
-pub extern fn engine_db_libfile_flag(this: &LibFile) -> i32 {
- this.flag()
+pub extern fn engine_db_libfile_flag(obj: &LibFile) -> i32 {
+ obj.flag()
}
#[no_mangle]
-pub extern fn engine_db_libfile_property(this: &LibFile, idx: PropertyIndex) -> i32 {
- this.property(unsafe { transmute(idx) })
+pub extern fn engine_db_libfile_property(obj: &LibFile, idx: PropertyIndex) -> i32 {
+ obj.property(unsafe { transmute(idx) })
}
#[no_mangle]
-pub extern fn engine_db_libfile_file_type(this: &LibFile) -> FileType {
- this.file_type()
+pub extern fn engine_db_libfile_file_type(obj: &LibFile) -> FileType {
+ obj.file_type()
}
#[no_mangle]
-pub extern fn engine_db_libfile_set_orientation(this: &mut LibFile, o: i32) {
- this.set_orientation(o);
+pub extern fn engine_db_libfile_set_orientation(obj: &mut LibFile, o: i32) {
+ obj.set_orientation(o);
}
#[no_mangle]
-pub extern fn engine_db_libfile_set_rating(this: &mut LibFile, r: i32) {
- this.set_rating(r);
+pub extern fn engine_db_libfile_set_rating(obj: &mut LibFile, r: i32) {
+ obj.set_rating(r);
}
#[no_mangle]
-pub extern fn engine_db_libfile_set_label(this: &mut LibFile, l: i32) {
- this.set_label(l);
+pub extern fn engine_db_libfile_set_label(obj: &mut LibFile, l: i32) {
+ obj.set_label(l);
}
#[no_mangle]
-pub extern fn engine_db_libfile_set_flag(this: &mut LibFile, f: i32) {
- this.set_flag(f);
+pub extern fn engine_db_libfile_set_flag(obj: &mut LibFile, f: i32) {
+ obj.set_flag(f);
}
#[no_mangle]
-pub extern fn engine_db_libfile_set_property(this: &mut LibFile, idx: PropertyIndex, v: i32) {
- this.set_property(unsafe { transmute(idx) }, v);
+pub extern fn engine_db_libfile_set_property(obj: &mut LibFile, idx: PropertyIndex, v: i32) {
+ obj.set_property(unsafe { transmute(idx) }, v);
}
#[no_mangle]
-pub extern fn engine_db_libfile_set_file_type(this: &mut LibFile, t: FileType) {
- this.set_file_type(t);
+pub extern fn engine_db_libfile_set_file_type(obj: &mut LibFile, t: FileType) {
+ obj.set_file_type(t);
}
diff --git a/src/engine/db/libfolder.hpp b/src/engine/db/libfolder.hpp
index 7fbfa70..703b6df 100644
--- a/src/engine/db/libfolder.hpp
+++ b/src/engine/db/libfolder.hpp
@@ -46,12 +46,6 @@ enum class LibFolderVirtualType {
LibFolderPtr libfolder_new(library_id_t id, const char *name);
-extern "C" {
-library_id_t engine_db_libfolder_id(const LibFolder *);
-void engine_db_libfolder_set_locked(const LibFolder *, bool);
-void engine_db_libfolder_set_expanded(const LibFolder *, bool);
-void engine_db_libfolder_set_virtual_type(const LibFolder *, int32_t);
-}
}
/*
diff --git a/src/engine/db/libmetadata.hpp b/src/engine/db/libmetadata.hpp
index 273a2d9..e800c56 100644
--- a/src/engine/db/libmetadata.hpp
+++ b/src/engine/db/libmetadata.hpp
@@ -26,7 +26,6 @@
#include "engine/db/librarytypes.hpp"
#include "engine/db/metadata.hpp"
#include "fwk/base/propertybag.hpp"
-#include "fwk/utils/exempi.hpp"
#include "rust_bindings.hpp"
diff --git a/src/engine/db/library.cpp b/src/engine/db/library.cpp
index 50e1583..152dd17 100644
--- a/src/engine/db/library.cpp
+++ b/src/engine/db/library.cpp
@@ -19,16 +19,12 @@
#include "library.hpp"
-extern "C" eng::Library *engine_db_library_new(const char *dir,
- uint64_t notif_id);
-extern "C" void engine_db_library_delete(eng::Library *);
-
namespace eng {
LibraryPtr library_new(const char *dir, uint64_t notif_id)
{
- return LibraryPtr(engine_db_library_new(dir, notif_id),
- &engine_db_library_delete);
+ return LibraryPtr(ffi::engine_db_library_new(dir, notif_id),
+ &ffi::engine_db_library_delete);
}
}
/*
diff --git a/src/engine/db/library.hpp b/src/engine/db/library.hpp
index bc3cfc0..ced40bc 100644
--- a/src/engine/db/library.hpp
+++ b/src/engine/db/library.hpp
@@ -21,15 +21,17 @@
#include <memory>
+#include "rust_bindings.hpp"
+
namespace eng {
+#if RUST_BINDGEN
class Library;
+#endif
typedef std::shared_ptr<Library> LibraryPtr;
LibraryPtr library_new(const char *dir, uint64_t notif_id);
-/** Whether to import managed. */
-enum class LibraryManaged { NO = 0, YES };
}
extern "C" bool engine_db_library_ok(const eng::Library *library);
diff --git a/src/engine/db/library.rs b/src/engine/db/library.rs
index bd33344..5eb2fcd 100644
--- a/src/engine/db/library.rs
+++ b/src/engine/db/library.rs
@@ -44,7 +44,13 @@ use engine::library::notification::engine_library_notify;
use fwk;
use fwk::PropertyValue;
use root::eng::NiepceProperties as Np;
-pub use root::eng::LibraryManaged as Managed;
+
+#[repr(i32)]
+#[derive(PartialEq,Clone)]
+pub enum Managed {
+ NO = 0,
+ YES = 1
+}
const DB_SCHEMA_VERSION: i32 = 6;
const DATABASENAME: &str = "niepcelibrary.db";
@@ -820,7 +826,7 @@ impl Library {
}
#[no_mangle]
-pub extern fn engine_db_library_new(path: *const c_char, notif_id: u64) -> *mut Library {
+pub extern "C" fn engine_db_library_new(path: *const c_char, notif_id: u64) -> *mut Library {
let l = Box::new(
Library::new(PathBuf::from(&*unsafe { CStr::from_ptr(path) }.to_string_lossy()),
notif_id));
@@ -828,12 +834,12 @@ pub extern fn engine_db_library_new(path: *const c_char, notif_id: u64) -> *mut
}
#[no_mangle]
-pub extern fn engine_db_library_delete(l: *mut Library) {
+pub extern "C" fn engine_db_library_delete(l: *mut Library) {
unsafe { Box::from_raw(l); }
}
#[no_mangle]
-pub extern fn engine_db_library_ok(l: &Library) -> bool {
+pub extern "C" fn engine_db_library_ok(l: &Library) -> bool {
l.is_ok()
}
diff --git a/src/engine/importer/cameraimporter.cpp b/src/engine/importer/cameraimporter.cpp
index 433de13..8dbdb99 100644
--- a/src/engine/importer/cameraimporter.cpp
+++ b/src/engine/importer/cameraimporter.cpp
@@ -133,7 +133,7 @@ bool CameraImporter::do_import(const std::string& source, const std::string& des
imported_camera_file->name(),
output_path)) {
// XXX else report error.
- importer(output_path, IImporter::Import::SINGLE, LibraryManaged::NO);
+ importer(output_path, IImporter::Import::SINGLE, Managed::NO);
}
}
return true;
diff --git a/src/engine/importer/directoryimporter.cpp b/src/engine/importer/directoryimporter.cpp
index 18918f6..3eed11a 100644
--- a/src/engine/importer/directoryimporter.cpp
+++ b/src/engine/importer/directoryimporter.cpp
@@ -94,7 +94,7 @@ bool DirectoryImporter::do_import(const std::string& source, const std::string&
const FileImporter& callback)
{
// pretty trivial, we have the source path.
- callback(source, IImporter::Import::DIRECTORY, LibraryManaged::NO);
+ callback(source, IImporter::Import::DIRECTORY, Managed::NO);
// XXX return a real error
return true;
diff --git a/src/engine/importer/iimporter.hpp b/src/engine/importer/iimporter.hpp
index 0c5c092..25d9617 100644
--- a/src/engine/importer/iimporter.hpp
+++ b/src/engine/importer/iimporter.hpp
@@ -28,6 +28,8 @@
#include "engine/db/library.hpp"
#include "engine/importer/importedfile.hpp"
+#include "rust_bindings.hpp"
+
namespace eng {
/**
@@ -57,7 +59,7 @@ public:
DIRECTORY
};
/** file importer callback */
- typedef std::function<void (const std::string&, Import, LibraryManaged)> FileImporter;
+ typedef std::function<void (const std::string&, Import, Managed)> FileImporter;
/** perform import from source
* @param source the source identified by a string.
* @param dest_dir the suggested destination directory is the importer needs to copy
diff --git a/src/engine/library/commands.rs b/src/engine/library/commands.rs
index ab2f5e0..c33d62a 100644
--- a/src/engine/library/commands.rs
+++ b/src/engine/library/commands.rs
@@ -19,6 +19,7 @@
use libc::c_char;
use std::ffi::CStr;
+use std::os::raw::c_void;
use std::path::Path;
use fwk::PropertyValue;
@@ -37,12 +38,11 @@ use super::notification::{
FolderCount,
MetadataChange,
};
-use root::eng::LibFile as CLibFile;
use root::eng::NiepceProperties as Np;
use root::fwk::FileList;
#[no_mangle]
-pub fn cmd_list_all_keywords(lib: &Library) -> bool {
+pub extern "C" fn cmd_list_all_keywords(lib: &Library) -> bool {
let list = lib.get_all_keywords();
// XXX change this to "LoadKeywords"
for kw in list {
@@ -52,7 +52,7 @@ pub fn cmd_list_all_keywords(lib: &Library) -> bool {
}
#[no_mangle]
-pub fn cmd_list_all_folders(lib: &Library) -> bool {
+pub extern "C" fn cmd_list_all_folders(lib: &Library) -> bool {
let list = lib.get_all_folders();
// XXX change this to "LoadedFodlers"
for folder in list {
@@ -62,7 +62,7 @@ pub fn cmd_list_all_folders(lib: &Library) -> bool {
}
#[no_mangle]
-pub fn cmd_import_file(lib: &Library, file_path: *const c_char, manage: Managed) -> bool {
+pub extern "C" fn cmd_import_file(lib: &Library, file_path: *const c_char, manage: Managed) -> bool {
dbg_assert!(manage == Managed::NO, "managing file is currently unsupported");
let path = String::from(unsafe { CStr::from_ptr(file_path) }.to_string_lossy());
@@ -92,7 +92,7 @@ pub fn cmd_import_file(lib: &Library, file_path: *const c_char, manage: Managed)
}
#[no_mangle]
-pub fn cmd_import_files(lib: &Library, folder: *const c_char, files: &mut FileList,
+pub extern "C" fn cmd_import_files(lib: &Library, folder: *const c_char, files: &mut FileList,
manage: Managed) -> bool {
dbg_assert!(manage == Managed::NO, "managing file is currently unsupported");
@@ -120,7 +120,7 @@ pub fn cmd_import_files(lib: &Library, folder: *const c_char, files: &mut FileLi
}
#[no_mangle]
-pub fn cmd_request_metadata(lib: &Library, file_id: LibraryId) -> bool {
+pub extern "C" fn cmd_request_metadata(lib: &Library, file_id: LibraryId) -> bool {
if let Some(lm) = lib.get_metadata(file_id) {
lib.notify(Box::new(LibNotification::MetadataQueried(lm)));
return true;
@@ -129,13 +129,13 @@ pub fn cmd_request_metadata(lib: &Library, file_id: LibraryId) -> bool {
}
#[no_mangle]
-pub fn cmd_query_folder_content(lib: &Library, folder_id: LibraryId) -> bool {
+pub extern "C" fn cmd_query_folder_content(lib: &Library, folder_id: LibraryId) -> bool {
let fl = lib.get_folder_content(folder_id);
let mut value = Box::new(
LibNotification::FolderContentQueried(unsafe { Content::new(folder_id) }));
if let LibNotification::FolderContentQueried(ref mut content) = *value {
for f in fl {
- unsafe { content.push(Box::into_raw(Box::new(f)) as *mut CLibFile) };
+ unsafe { content.push(Box::into_raw(Box::new(f)) as *mut c_void) };
}
}
lib.notify(value);
@@ -143,7 +143,7 @@ pub fn cmd_query_folder_content(lib: &Library, folder_id: LibraryId) -> bool {
}
#[no_mangle]
-pub fn cmd_set_metadata(lib: &Library, id: LibraryId, meta: Np,
+pub extern "C" fn cmd_set_metadata(lib: &Library, id: LibraryId, meta: Np,
value: &PropertyValue) -> bool {
lib.set_metadata(id, meta, value);
lib.notify(Box::new(LibNotification::MetadataChanged(
@@ -152,7 +152,7 @@ pub fn cmd_set_metadata(lib: &Library, id: LibraryId, meta: Np,
}
#[no_mangle]
-pub fn cmd_count_folder(lib: &Library, folder_id: LibraryId) -> bool {
+pub extern "C" fn cmd_count_folder(lib: &Library, folder_id: LibraryId) -> bool {
let count = lib.count_folder(folder_id);
lib.notify(Box::new(LibNotification::FolderCounted(
FolderCount{folder: folder_id, count: count})));
@@ -160,23 +160,23 @@ pub fn cmd_count_folder(lib: &Library, folder_id: LibraryId) -> bool {
}
#[no_mangle]
-pub fn cmd_query_keyword_content(lib: &Library, keyword_id: LibraryId) -> bool {
+pub extern "C" fn cmd_query_keyword_content(lib: &Library, keyword_id: LibraryId) -> bool {
let fl = lib.get_keyword_content(keyword_id);
let mut content = unsafe { Content::new(keyword_id) };
for f in fl {
- unsafe { content.push(Box::into_raw(Box::new(f)) as *mut CLibFile) };
+ unsafe { content.push(Box::into_raw(Box::new(f)) as *mut c_void) };
}
lib.notify(Box::new(LibNotification::KeywordContentQueried(content)));
true
}
#[no_mangle]
-pub fn cmd_write_metadata(lib: &Library, file_id: LibraryId) -> bool {
+pub extern "C" fn cmd_write_metadata(lib: &Library, file_id: LibraryId) -> bool {
lib.write_metadata(file_id)
}
#[no_mangle]
-pub fn cmd_move_file_to_folder(lib: &Library, file_id: LibraryId, from: LibraryId,
+pub extern "C" fn cmd_move_file_to_folder(lib: &Library, file_id: LibraryId, from: LibraryId,
to: LibraryId) -> bool {
if lib.move_file_to_folder(file_id, to) {
@@ -192,7 +192,7 @@ pub fn cmd_move_file_to_folder(lib: &Library, file_id: LibraryId, from: LibraryI
}
#[no_mangle]
-pub fn cmd_list_all_labels(lib: &Library) -> bool {
+pub extern "C" fn cmd_list_all_labels(lib: &Library) -> bool {
let l = lib.get_all_labels();
// XXX change this notification type
for label in l {
@@ -202,7 +202,7 @@ pub fn cmd_list_all_labels(lib: &Library) -> bool {
}
#[no_mangle]
-pub fn cmd_create_label(lib: &Library, name: *const c_char, colour: *const c_char) -> bool {
+pub extern "C" fn cmd_create_label(lib: &Library, name: *const c_char, colour: *const c_char) -> bool {
let name = unsafe { CStr::from_ptr(name) }.to_string_lossy();
let colour = unsafe { CStr::from_ptr(colour) }.to_string_lossy();
let id = lib.add_label(&name, &colour);
@@ -214,14 +214,14 @@ pub fn cmd_create_label(lib: &Library, name: *const c_char, colour: *const c_cha
}
#[no_mangle]
-pub fn cmd_delete_label(lib: &Library, label_id: LibraryId) -> bool {
+pub extern "C" fn cmd_delete_label(lib: &Library, label_id: LibraryId) -> bool {
lib.delete_label(label_id);
lib.notify(Box::new(LibNotification::LabelDeleted(label_id)));
true
}
#[no_mangle]
-pub fn cmd_update_label(lib: &Library, label_id: LibraryId, name: *const c_char,
+pub extern "C" fn cmd_update_label(lib: &Library, label_id: LibraryId, name: *const c_char,
colour: *const c_char) -> bool {
let name = unsafe { CStr::from_ptr(name) }.to_string_lossy();
let colour = unsafe { CStr::from_ptr(colour) }.to_string_lossy();
@@ -232,6 +232,6 @@ pub fn cmd_update_label(lib: &Library, label_id: LibraryId, name: *const c_char,
}
#[no_mangle]
-pub fn cmd_process_xmp_update_queue(lib: &Library, write_xmp: bool) -> bool {
+pub extern "C" fn cmd_process_xmp_update_queue(lib: &Library, write_xmp: bool) -> bool {
lib.process_xmp_update_queue(write_xmp)
}
diff --git a/src/engine/library/notification.cpp b/src/engine/library/notification.cpp
index 1bc6731..d7e470c 100644
--- a/src/engine/library/notification.cpp
+++ b/src/engine/library/notification.cpp
@@ -19,7 +19,6 @@
*/
#include "engine/library/notification.hpp"
-#include "engine/db/keyword.hpp"
#include "fwk/base/debug.hpp"
#include "fwk/toolkit/notificationcenter.hpp"
#include "niepce/notifications.hpp"
diff --git a/src/engine/library/notification.hpp b/src/engine/library/notification.hpp
index 4be3a1a..ef1adec 100644
--- a/src/engine/library/notification.hpp
+++ b/src/engine/library/notification.hpp
@@ -28,47 +28,27 @@
#include "rust_bindings.hpp"
+namespace ffi {
+#if RUST_BINDGEN
+class LibFile;
+#endif
+}
+
namespace eng {
#if RUST_BINDGEN
-class Keyword;
-class Label;
-class LibFolder;
-class LibMetadata;
class LibNotification;
#endif
typedef std::shared_ptr<eng::LibNotification> LibNotificationPtr;
-class MetadataChange;
-class FolderCount;
-class FileMove;
-
-enum class LibNotificationType {
- NONE = 0,
- NEW_LIBRARY_CREATED,
- ADDED_FOLDER,
- ADDED_FILE,
- ADDED_FILES,
- ADDED_KEYWORD,
- ADDED_LABEL,
- FOLDER_CONTENT_QUERIED,
- KEYWORD_CONTENT_QUERIED,
- METADATA_QUERIED,
- METADATA_CHANGED,
- LABEL_CHANGED,
- LABEL_DELETED,
- XMP_NEEDS_UPDATE,
- FOLDER_COUNTED,
- FOLDER_COUNT_CHANGE,
- FILE_MOVED
-};
struct QueriedContent {
library_id_t container;
LibFileListPtr files;
QueriedContent(library_id_t container);
- void push(LibFile*);
+ // void instead of LibFile because bindgen fail to generate the proper type
+ void push(void*);
};
}
diff --git a/src/engine/library/notification.rs b/src/engine/library/notification.rs
index 61d4c1c..cebe263 100644
--- a/src/engine/library/notification.rs
+++ b/src/engine/library/notification.rs
@@ -28,7 +28,7 @@ use root::eng::QueriedContent;
pub type Content = QueriedContent;
-#[repr(C)]
+#[repr(i32)]
#[allow(non_camel_case_types)]
pub enum NotificationType {
NONE = 0,
@@ -122,7 +122,7 @@ pub extern "C" fn engine_library_notification_delete(n: *mut Notification) {
}
#[no_mangle]
-pub extern "C" fn engine_library_notification_type(n: *const Notification) -> i32 {
+pub extern "C" fn engine_library_notification_type(n: *const Notification) -> NotificationType {
let t = match unsafe { n.as_ref() } {
Some(&Notification::AddedFile) => NotificationType::ADDED_FILE,
Some(&Notification::AddedFiles) => NotificationType::ADDED_FILES,
@@ -143,7 +143,7 @@ pub extern "C" fn engine_library_notification_type(n: *const Notification) -> i3
Some(&Notification::XmpNeedsUpdate) => NotificationType::XMP_NEEDS_UPDATE,
None => unreachable!(),
};
- t as i32
+ t
}
diff --git a/src/libraryclient/clientimpl.cpp b/src/libraryclient/clientimpl.cpp
index f29a89c..3a3aa40 100644
--- a/src/libraryclient/clientimpl.cpp
+++ b/src/libraryclient/clientimpl.cpp
@@ -20,14 +20,15 @@
#include "fwk/base/debug.hpp"
#include "fwk/utils/files.hpp"
#include "engine/library/op.hpp"
-#include "engine/library/commands.hpp"
#include "libraryclient.hpp"
#include "clientimpl.hpp"
#include "locallibraryserver.hpp"
+#include "rust_bindings.hpp"
+
using fwk::FileListPtr;
using eng::Op;
-using eng::LibraryManaged;
+using eng::Managed;
using eng::tid_t;
namespace libraryclient {
@@ -70,19 +71,19 @@ tid_t ClientImpl::schedule_op(const Op::Function & func)
tid_t ClientImpl::getAllKeywords()
{
- return schedule_op(&cmd_list_all_keywords);
+ return schedule_op(&ffi::cmd_list_all_keywords);
}
tid_t ClientImpl::getAllFolders()
{
- return schedule_op(&cmd_list_all_folders);
+ return schedule_op(&ffi::cmd_list_all_folders);
}
tid_t ClientImpl::queryFolderContent(eng::library_id_t folder_id)
{
return schedule_op([folder_id](const auto& lib) {
- return cmd_query_folder_content(lib, folder_id);
+ return ffi::cmd_query_folder_content(lib, folder_id);
});
}
@@ -90,7 +91,7 @@ tid_t ClientImpl::queryFolderContent(eng::library_id_t folder_id)
tid_t ClientImpl::countFolder(eng::library_id_t folder_id)
{
return schedule_op([folder_id](const auto& lib) {
- return cmd_count_folder(lib, folder_id);
+ return ffi::cmd_count_folder(lib, folder_id);
});
}
@@ -98,7 +99,7 @@ tid_t ClientImpl::countFolder(eng::library_id_t folder_id)
tid_t ClientImpl::queryKeywordContent(eng::library_id_t keyword_id)
{
return schedule_op([keyword_id](const auto& lib) {
- return cmd_query_keyword_content(lib, keyword_id);
+ return ffi::cmd_query_keyword_content(lib, keyword_id);
});
}
@@ -106,23 +107,23 @@ tid_t ClientImpl::queryKeywordContent(eng::library_id_t keyword_id)
tid_t ClientImpl::requestMetadata(eng::library_id_t file_id)
{
return schedule_op([file_id](const auto& lib) {
- return cmd_request_metadata(lib, file_id);
+ return ffi::cmd_request_metadata(lib, file_id);
});
}
-tid_t ClientImpl::setMetadata(eng::library_id_t file_id, int meta,
+tid_t ClientImpl::setMetadata(eng::library_id_t file_id, eng::Np meta,
const fwk::PropertyValuePtr & value)
{
return schedule_op([file_id, meta, value](const auto& lib) {
- return cmd_set_metadata(lib, file_id, meta, value.get());
+ return ffi::cmd_set_metadata(lib, file_id, meta, value.get());
});
}
tid_t ClientImpl::write_metadata(eng::library_id_t file_id)
{
return schedule_op([file_id](const auto& lib) {
- return cmd_write_metadata(lib, file_id);
+ return ffi::cmd_write_metadata(lib, file_id);
});
}
@@ -131,28 +132,28 @@ tid_t ClientImpl::moveFileToFolder(eng::library_id_t file_id,
eng::library_id_t to_folder_id)
{
return schedule_op([file_id, from_folder_id, to_folder_id](const auto& lib) {
- return cmd_move_file_to_folder(lib, file_id, from_folder_id, to_folder_id);
+ return ffi::cmd_move_file_to_folder(lib, file_id, from_folder_id, to_folder_id);
});
}
tid_t ClientImpl::getAllLabels()
{
- return schedule_op(&cmd_list_all_labels);
+ return schedule_op(&ffi::cmd_list_all_labels);
}
tid_t ClientImpl::createLabel(const std::string & s, const std::string & colour)
{
return schedule_op([s, colour](const auto& lib) {
- return cmd_create_label(lib, s.c_str(), colour.c_str());
+ return ffi::cmd_create_label(lib, s.c_str(), colour.c_str());
});
}
tid_t ClientImpl::deleteLabel(int label_id)
{
return schedule_op([label_id](const auto& lib) {
- return cmd_delete_label(lib, label_id);
+ return ffi::cmd_delete_label(lib, label_id);
});
}
@@ -161,7 +162,7 @@ tid_t ClientImpl::updateLabel(eng::library_id_t label_id,
const std::string & new_colour)
{
return schedule_op([label_id, new_name, new_colour](const auto& lib) {
- return cmd_update_label(lib, label_id, new_name.c_str(), new_colour.c_str());
+ return ffi::cmd_update_label(lib, label_id, new_name.c_str(), new_colour.c_str());
});
}
@@ -169,25 +170,25 @@ tid_t ClientImpl::updateLabel(eng::library_id_t label_id,
tid_t ClientImpl::processXmpUpdateQueue(bool write_xmp)
{
return schedule_op([write_xmp](const auto& lib) {
- return cmd_process_xmp_update_queue(lib, write_xmp);
+ return ffi::cmd_process_xmp_update_queue(lib, write_xmp);
});
}
-tid_t ClientImpl::importFile(const std::string & path, LibraryManaged manage)
+tid_t ClientImpl::importFile(const std::string & path, Managed manage)
{
return schedule_op([path, manage](const auto& lib) {
- return cmd_import_file(lib, path.c_str(), manage);
+ return ffi::cmd_import_file(lib, path.c_str(), manage);
});
}
-tid_t ClientImpl::importFromDirectory(const std::string & dir, LibraryManaged manage)
+tid_t ClientImpl::importFromDirectory(const std::string & dir, Managed manage)
{
FileListPtr files;
files = fwk::FileList::getFilesFromDirectory(dir, &fwk::filter_none);
return schedule_op([dir, files, manage](const auto& lib) {
- return cmd_import_files(lib, dir.c_str(), files.get(), manage);
+ return ffi::cmd_import_files(lib, dir.c_str(), files.get(), manage);
});
}
diff --git a/src/libraryclient/clientimpl.hpp b/src/libraryclient/clientimpl.hpp
index 333358b..f3adac3 100644
--- a/src/libraryclient/clientimpl.hpp
+++ b/src/libraryclient/clientimpl.hpp
@@ -48,7 +48,7 @@ public:
eng::tid_t queryFolderContent(eng::library_id_t id);
eng::tid_t countFolder(eng::library_id_t id);
eng::tid_t requestMetadata(eng::library_id_t id);
- eng::tid_t setMetadata(eng::library_id_t id, int meta,
+ eng::tid_t setMetadata(eng::library_id_t id, eng::Np meta,
const fwk::PropertyValuePtr & value);
eng::tid_t write_metadata(eng::library_id_t file_id);
@@ -64,8 +64,8 @@ public:
eng::tid_t processXmpUpdateQueue(bool write_xmp);
- eng::tid_t importFile(const std::string & path, eng::LibraryManaged manage);
- eng::tid_t importFromDirectory(const std::string & dir, eng::LibraryManaged manage);
+ eng::tid_t importFile(const std::string & path, eng::Managed manage);
+ eng::tid_t importFromDirectory(const std::string & dir, eng::Managed manage);
protected:
const fwk::Moniker m_moniker;
diff --git a/src/libraryclient/libraryclient.cpp b/src/libraryclient/libraryclient.cpp
index a709d92..6837ea5 100644
--- a/src/libraryclient/libraryclient.cpp
+++ b/src/libraryclient/libraryclient.cpp
@@ -92,7 +92,7 @@ eng::tid_t LibraryClient::requestMetadata(eng::library_id_t id)
eng::tid_t LibraryClient::setMetadata(library_id_t id, fwk::PropertyIndex meta,
const fwk::PropertyValuePtr & value)
{
- return m_pImpl->setMetadata(id, meta, value);
+ return m_pImpl->setMetadata(id, static_cast<eng::Np>(meta), value);
}
eng::tid_t LibraryClient::write_metadata(eng::library_id_t id)
@@ -136,12 +136,12 @@ eng::tid_t LibraryClient::processXmpUpdateQueue(bool write_xmp)
return m_pImpl->processXmpUpdateQueue(write_xmp);
}
-void LibraryClient::importFile(const std::string & path, eng::LibraryManaged manage)
+void LibraryClient::importFile(const std::string & path, eng::Managed manage)
{
m_pImpl->importFile(path, manage);
}
-void LibraryClient::importFromDirectory(const std::string & dir, eng::LibraryManaged manage)
+void LibraryClient::importFromDirectory(const std::string & dir, eng::Managed manage)
{
m_pImpl->importFromDirectory(dir, manage);
}
diff --git a/src/libraryclient/libraryclient.hpp b/src/libraryclient/libraryclient.hpp
index 2fe91f0..88cc9fb 100644
--- a/src/libraryclient/libraryclient.hpp
+++ b/src/libraryclient/libraryclient.hpp
@@ -87,13 +87,13 @@ public:
* @param path the file path
* @param manage true if imported file have to be managed
*/
- void importFile(const std::string & path, eng::LibraryManaged manage);
+ void importFile(const std::string & path, eng::Managed manage);
/** Import files from a directory
* @param dir the directory
* @param manage true if imports have to be managed
*/
- void importFromDirectory(const std::string & dir, eng::LibraryManaged manage);
+ void importFromDirectory(const std::string & dir, eng::Managed manage);
eng::ThumbnailCache & thumbnailCache()
{ return m_thumbnailCache; }
diff --git a/src/niepce/modules/darkroom/darkroommodule.cpp b/src/niepce/modules/darkroom/darkroommodule.cpp
index f7a832e..43ec563 100644
--- a/src/niepce/modules/darkroom/darkroommodule.cpp
+++ b/src/niepce/modules/darkroom/darkroommodule.cpp
@@ -51,8 +51,8 @@ void DarkroomModule::reload_image()
// currently we treat RAW + JPEG as RAW.
// TODO: have a way to actually choose the JPEG.
auto file_type = engine_db_libfile_file_type(file.get());
- bool isRaw = (file_type == eng::LibFileType::RAW)
- || (file_type == eng::LibFileType::RAW_JPEG);
+ bool isRaw = (file_type == eng::FileType::RAW)
+ || (file_type == eng::FileType::RAW_JPEG);
std::string path = engine_db_libfile_path(file.get());
m_image->reload(path, isRaw, engine_db_libfile_orientation(file.get()));
}
diff --git a/src/niepce/modules/map/mapmodule.cpp b/src/niepce/modules/map/mapmodule.cpp
index 601b94c..22d2f58 100644
--- a/src/niepce/modules/map/mapmodule.cpp
+++ b/src/niepce/modules/map/mapmodule.cpp
@@ -71,8 +71,8 @@ MapModule::on_lib_notification(const eng::LibNotification &ln)
if (!m_active) {
return;
}
- switch(static_cast<eng::LibNotificationType>(engine_library_notification_type(&ln))) {
- case eng::LibNotificationType::METADATA_QUERIED:
+ switch (engine_library_notification_type(&ln)) {
+ case eng::NotificationType::METADATA_QUERIED:
{
auto lm = engine_library_notification_get_libmetadata(&ln);
DBG_OUT("received metadata in MapModule");
diff --git a/src/niepce/ui/gridviewmodule.cpp b/src/niepce/ui/gridviewmodule.cpp
index aa62d9c..6bf9e56 100644
--- a/src/niepce/ui/gridviewmodule.cpp
+++ b/src/niepce/ui/gridviewmodule.cpp
@@ -54,8 +54,8 @@ GridViewModule::~GridViewModule()
void
GridViewModule::on_lib_notification(const eng::LibNotification &ln)
{
- switch(static_cast<eng::LibNotificationType>(engine_library_notification_type(&ln))) {
- case eng::LibNotificationType::METADATA_QUERIED:
+ switch (engine_library_notification_type(&ln)) {
+ case eng::NotificationType::METADATA_QUERIED:
{
auto lm = engine_library_notification_get_libmetadata(&ln);
DBG_OUT("received metadata");
@@ -66,7 +66,7 @@ GridViewModule::on_lib_notification(const eng::LibNotification &ln)
}
break;
}
- case eng::LibNotificationType::METADATA_CHANGED:
+ case eng::NotificationType::METADATA_CHANGED:
{
DBG_OUT("metadata changed");
auto id = engine_library_notification_get_id(&ln);
diff --git a/src/niepce/ui/imageliststore.cpp b/src/niepce/ui/imageliststore.cpp
index 7ecadbd..7ab0b42 100644
--- a/src/niepce/ui/imageliststore.cpp
+++ b/src/niepce/ui/imageliststore.cpp
@@ -92,17 +92,17 @@ Gtk::TreePath ImageListStore::get_path_from_id(eng::library_id_t id)
void ImageListStore::on_lib_notification(const eng::LibNotification &ln)
{
- auto type = static_cast<eng::LibNotificationType>(engine_library_notification_type(&ln));
+ auto type = engine_library_notification_type(&ln);
switch (type) {
- case eng::LibNotificationType::FOLDER_CONTENT_QUERIED:
- case eng::LibNotificationType::KEYWORD_CONTENT_QUERIED:
+ case eng::NotificationType::FOLDER_CONTENT_QUERIED:
+ case eng::NotificationType::KEYWORD_CONTENT_QUERIED:
{
auto param = engine_library_notification_get_content(&ln);
const auto& l = param->files;
- if (type == eng::LibNotificationType::FOLDER_CONTENT_QUERIED) {
+ if (type == eng::NotificationType::FOLDER_CONTENT_QUERIED) {
m_current_folder = param->container;
m_current_keyword = 0;
- } else if (type == eng::LibNotificationType::KEYWORD_CONTENT_QUERIED) {
+ } else if (type == eng::NotificationType::KEYWORD_CONTENT_QUERIED) {
m_current_folder = 0;
m_current_keyword = param->container;
}
@@ -125,7 +125,7 @@ void ImageListStore::on_lib_notification(const eng::LibNotification &ln)
getLibraryClient()->thumbnailCache().request(*l);
break;
}
- case eng::LibNotificationType::FILE_MOVED:
+ case eng::NotificationType::FILE_MOVED:
{
DBG_OUT("File moved. Current folder %ld", m_current_folder);
auto param = engine_library_notification_get_filemoved(&ln);
@@ -144,7 +144,7 @@ void ImageListStore::on_lib_notification(const eng::LibNotification &ln)
}
break;
}
- case eng::LibNotificationType::METADATA_CHANGED:
+ case eng::NotificationType::METADATA_CHANGED:
{
auto m = engine_library_notification_get_metadatachange(&ln);
const fwk::PropertyIndex& prop = m->meta;
@@ -164,7 +164,7 @@ void ImageListStore::on_lib_notification(const eng::LibNotification &ln)
}
break;
}
- case eng::LibNotificationType::XMP_NEEDS_UPDATE:
+ case eng::NotificationType::XMP_NEEDS_UPDATE:
{
fwk::Configuration & cfg = fwk::Application::app()->config();
int write_xmp = false;
diff --git a/src/niepce/ui/librarycellrenderer.cpp b/src/niepce/ui/librarycellrenderer.cpp
index 3535f28..8cd054a 100644
--- a/src/niepce/ui/librarycellrenderer.cpp
+++ b/src/niepce/ui/librarycellrenderer.cpp
@@ -252,16 +252,16 @@ LibraryCellRenderer::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
Cairo::RefPtr<Cairo::ImageSurface> emblem;
switch(engine_db_libfile_file_type(file.get())) {
- case eng::LibFileType::RAW:
+ case eng::FileType::RAW:
emblem = m_raw_format_emblem;
break;
- case eng::LibFileType::RAW_JPEG:
+ case eng::FileType::RAW_JPEG:
emblem = m_rawjpeg_format_emblem;
break;
- case eng::LibFileType::IMAGE:
+ case eng::FileType::IMAGE:
emblem = m_img_format_emblem;
break;
- case eng::LibFileType::VIDEO:
+ case eng::FileType::VIDEO:
emblem = m_video_format_emblem;
break;
default:
diff --git a/src/niepce/ui/niepcewindow.cpp b/src/niepce/ui/niepcewindow.cpp
index e0efdfc..6675cf0 100644
--- a/src/niepce/ui/niepcewindow.cpp
+++ b/src/niepce/ui/niepcewindow.cpp
@@ -48,12 +48,14 @@
#include "dialogs/editlabels.hpp"
#include "selectioncontroller.hpp"
+#include "rust_bindings.hpp"
+
using libraryclient::LibraryClient;
using libraryclient::LibraryClientPtr;
using fwk::Application;
using fwk::Configuration;
using fwk::UndoHistory;
-using eng::LibraryManaged;
+using eng::Managed;
using eng::IImporter;
namespace ui {
@@ -275,7 +277,7 @@ void NiepceWindow::on_action_file_import()
auto dest_dir = import_dialog->get_dest_dir();
importer->do_import(
source, dest_dir,
- [this] (const std::string & path, IImporter::Import type, LibraryManaged manage) {
+ [this] (const std::string & path, IImporter::Import type, Managed manage) {
if (type == IImporter::Import::SINGLE) {
m_libClient->importFile(path, manage);
} else {
@@ -336,11 +338,11 @@ void NiepceWindow::create_initial_labels()
void NiepceWindow::on_lib_notification(const eng::LibNotification& ln)
{
- switch(static_cast<eng::LibNotificationType>(engine_library_notification_type(&ln))) {
- case eng::LibNotificationType::NEW_LIBRARY_CREATED:
+ switch (engine_library_notification_type(&ln)) {
+ case eng::NotificationType::NEW_LIBRARY_CREATED:
create_initial_labels();
break;
- case eng::LibNotificationType::ADDED_LABEL:
+ case eng::NotificationType::ADDED_LABEL:
{
auto l = engine_library_notification_get_label(&ln);
if (l) {
@@ -350,7 +352,7 @@ void NiepceWindow::on_lib_notification(const eng::LibNotification& ln)
}
break;
}
- case eng::LibNotificationType::LABEL_CHANGED:
+ case eng::NotificationType::LABEL_CHANGED:
{
auto l = engine_library_notification_get_label(&ln);
if (l) {
@@ -360,7 +362,7 @@ void NiepceWindow::on_lib_notification(const eng::LibNotification& ln)
}
break;
}
- case eng::LibNotificationType::LABEL_DELETED:
+ case eng::NotificationType::LABEL_DELETED:
{
auto id = engine_library_notification_get_id(&ln);
if (id) {
diff --git a/src/niepce/ui/workspacecontroller.cpp b/src/niepce/ui/workspacecontroller.cpp
index aa8a9e4..00213e1 100644
--- a/src/niepce/ui/workspacecontroller.cpp
+++ b/src/niepce/ui/workspacecontroller.cpp
@@ -84,21 +84,21 @@ fwk::Configuration::Ptr WorkspaceController::getLibraryConfig() const
void WorkspaceController::on_lib_notification(const eng::LibNotification &ln)
{
DBG_OUT("notification for workspace");
- switch(static_cast<eng::LibNotificationType>(engine_library_notification_type(&ln))) {
- case eng::LibNotificationType::ADDED_FOLDER:
+ switch (engine_library_notification_type(&ln)) {
+ case eng::NotificationType::ADDED_FOLDER:
{
auto f = engine_library_notification_get_libfolder(&ln);
this->add_folder_item(f);
break;
}
- case eng::LibNotificationType::ADDED_KEYWORD:
+ case eng::NotificationType::ADDED_KEYWORD:
{
auto k = engine_library_notification_get_keyword(&ln);
DBG_ASSERT(k, "keyword must not be NULL");
add_keyword_item(k);
break;
}
- case eng::LibNotificationType::FOLDER_COUNTED:
+ case eng::NotificationType::FOLDER_COUNTED:
{
auto count = engine_library_notification_get_folder_count(&ln);
DBG_OUT("count for folder %Ld is %d", (long long)count->folder, count->count);
@@ -112,7 +112,7 @@ void WorkspaceController::on_lib_notification(const eng::LibNotification &ln)
break;
}
- case eng::LibNotificationType::FOLDER_COUNT_CHANGE:
+ case eng::NotificationType::FOLDER_COUNT_CHANGE:
{
auto count = engine_library_notification_get_folder_count(&ln);
DBG_OUT("count change for folder %Ld is %d", (long long)count->folder, count->count);
@@ -200,10 +200,11 @@ void WorkspaceController::add_keyword_item(const eng::Keyword* k)
{
auto children = m_keywordsNode->children();
bool was_empty = children.empty();
+ char* keyword = engine_db_keyword_keyword(k);
auto iter = add_item(m_treestore, children,
- m_icons[ICON_KEYWORD],
- engine_db_keyword_keyword(k),
+ m_icons[ICON_KEYWORD], keyword,
engine_db_keyword_id(k), KEYWORD_ITEM);
+ ffi::rust_cstring_delete(keyword);
// getLibraryClient()->countKeyword(f->id());
m_keywordsidmap[engine_db_keyword_id(k)] = iter;
if(was_empty) {
diff --git a/src/rust_bindings.hpp b/src/rust_bindings.hpp
index 1a157a8..848f3bb 100644
--- a/src/rust_bindings.hpp
+++ b/src/rust_bindings.hpp
@@ -21,11 +21,21 @@
#if !RUST_BINDGEN
+#include "engine/db/properties-enum.hpp"
+
+namespace fwk {
+class FileList;
+}
namespace eng {
class QueriedContent;
}
-using eng::QueriedContent;
+
+namespace ffi {
+typedef eng::QueriedContent QueriedContent;
+typedef eng::NiepceProperties Np;
+typedef fwk::FileList FileList;
+}
#include "target/bindings.h"
@@ -41,13 +51,18 @@ typedef ffi::RgbColour RgbColour;
}
namespace eng {
-
+typedef ffi::FileType FileType;
+typedef ffi::Library Library;
+typedef ffi::FileBundle FileBundle;
typedef ffi::Keyword Keyword;
+typedef ffi::LibFile LibFile;
typedef ffi::LibFolder LibFolder;
typedef ffi::LibMetadata LibMetadata;
typedef ffi::Label Label;
+typedef ffi::Managed Managed;
typedef ffi::Notification LibNotification;
-
+typedef ffi::NotificationType NotificationType;
+typedef ffi::Np Np;
}
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]