Remove all libimagentryref usage
This commit is contained in:
parent
5457834ea1
commit
3eab3af7b0
6 changed files with 7 additions and 76 deletions
|
@ -33,12 +33,6 @@ libimagstore = { version = "0.8.0", path = "../../../lib/core/libimagstore"
|
||||||
libimagerror = { version = "0.8.0", path = "../../../lib/core/libimagerror" }
|
libimagerror = { version = "0.8.0", path = "../../../lib/core/libimagerror" }
|
||||||
libimagentryutil = { version = "0.8.0", path = "../../../lib/entry/libimagentryutil/" }
|
libimagentryutil = { version = "0.8.0", path = "../../../lib/entry/libimagentryutil/" }
|
||||||
|
|
||||||
[dependencies.libimagentryref]
|
|
||||||
version = "0.8.0"
|
|
||||||
path = "../../../lib/entry/libimagentryref/"
|
|
||||||
default-features = false
|
|
||||||
features = ["generators", "generators-sha1"]
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
deser = ["serde", "serde_derive"]
|
deser = ["serde", "serde_derive"]
|
||||||
|
|
|
@ -22,7 +22,6 @@ use std::ops::Deref;
|
||||||
use vobject::Component;
|
use vobject::Component;
|
||||||
|
|
||||||
use libimagstore::store::Entry;
|
use libimagstore::store::Entry;
|
||||||
use libimagentryref::reference::Ref;
|
|
||||||
use libimagentryutil::isa::Is;
|
use libimagentryutil::isa::Is;
|
||||||
use libimagentryutil::isa::IsKindHeaderPathProvider;
|
use libimagentryutil::isa::IsKindHeaderPathProvider;
|
||||||
|
|
||||||
|
@ -30,9 +29,7 @@ use error::Result;
|
||||||
use util;
|
use util;
|
||||||
|
|
||||||
/// Trait to be implemented on ::libimagstore::store::Entry
|
/// Trait to be implemented on ::libimagstore::store::Entry
|
||||||
///
|
pub trait Contact {
|
||||||
/// Based on the functionality from libimagentryref, for fetching the Ical data from disk
|
|
||||||
pub trait Contact : Ref {
|
|
||||||
|
|
||||||
fn is_contact(&self) -> Result<bool>;
|
fn is_contact(&self) -> Result<bool>;
|
||||||
|
|
||||||
|
@ -53,13 +50,7 @@ impl Contact for Entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_contact_data(&self) -> Result<ContactData> {
|
fn get_contact_data(&self) -> Result<ContactData> {
|
||||||
let component = self
|
unimplemented!()
|
||||||
.get_path()
|
|
||||||
.map_err(From::from)
|
|
||||||
.and_then(util::read_to_string)
|
|
||||||
.and_then(util::parse)?;
|
|
||||||
|
|
||||||
Ok(ContactData(component))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ error_chain! {
|
||||||
|
|
||||||
links {
|
links {
|
||||||
StoreError(::libimagstore::error::StoreError, ::libimagstore::error::StoreErrorKind);
|
StoreError(::libimagstore::error::StoreError, ::libimagstore::error::StoreErrorKind);
|
||||||
RefError(::libimagentryref::error::RefError, ::libimagentryref::error::RefErrorKind);
|
|
||||||
VObjectError(::vobject::error::VObjectError, ::vobject::error::VObjectErrorKind);
|
VObjectError(::vobject::error::VObjectError, ::vobject::error::VObjectErrorKind);
|
||||||
EntryUtilError(::libimagentryutil::error::EntryUtilError, ::libimagentryutil::error::EntryUtilErrorKind);
|
EntryUtilError(::libimagentryutil::error::EntryUtilError, ::libimagentryutil::error::EntryUtilErrorKind);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,6 @@ use error::Result;
|
||||||
pub struct ContactIter<'a>(StoreIdIterator, &'a Store);
|
pub struct ContactIter<'a>(StoreIdIterator, &'a Store);
|
||||||
|
|
||||||
/// Iterator over contacts
|
/// Iterator over contacts
|
||||||
///
|
|
||||||
/// As the libimagcontact works with libimagentryref in the backend, we must hold a reference to the
|
|
||||||
/// Store here as well, so we can check whether a fetched StoreId actually points to a contact
|
|
||||||
/// reference or not.
|
|
||||||
///
|
|
||||||
/// So, the Iterator `Store::get()`s the object pointed to by the StoreId and returns it if
|
|
||||||
/// everything worked.
|
|
||||||
impl<'a> ContactIter<'a> {
|
impl<'a> ContactIter<'a> {
|
||||||
|
|
||||||
pub fn new(sii: StoreIdIterator, store: &'a Store) -> ContactIter<'a> {
|
pub fn new(sii: StoreIdIterator, store: &'a Store) -> ContactIter<'a> {
|
||||||
|
|
|
@ -42,7 +42,6 @@ extern crate uuid;
|
||||||
|
|
||||||
#[macro_use] extern crate libimagstore;
|
#[macro_use] extern crate libimagstore;
|
||||||
extern crate libimagerror;
|
extern crate libimagerror;
|
||||||
extern crate libimagentryref;
|
|
||||||
#[macro_use] extern crate libimagentryutil;
|
#[macro_use] extern crate libimagentryutil;
|
||||||
|
|
||||||
module_entry_path_mod!("contact");
|
module_entry_path_mod!("contact");
|
||||||
|
|
|
@ -26,8 +26,6 @@ use vobject::parse_component;
|
||||||
use libimagstore::store::Store;
|
use libimagstore::store::Store;
|
||||||
use libimagstore::store::FileLockEntry;
|
use libimagstore::store::FileLockEntry;
|
||||||
use libimagstore::storeid::StoreIdIterator;
|
use libimagstore::storeid::StoreIdIterator;
|
||||||
use libimagentryref::refstore::RefStore;
|
|
||||||
use libimagentryref::refstore::UniqueRefPathGenerator;
|
|
||||||
use libimagentryutil::isa::Is;
|
use libimagentryutil::isa::Is;
|
||||||
|
|
||||||
use contact::IsContact;
|
use contact::IsContact;
|
||||||
|
@ -36,45 +34,14 @@ use error::ContactErrorKind as CEK;
|
||||||
use error::Result;
|
use error::Result;
|
||||||
use util;
|
use util;
|
||||||
|
|
||||||
pub struct UniqueContactPathGenerator;
|
pub trait ContactStore<'a> {
|
||||||
impl UniqueRefPathGenerator for UniqueContactPathGenerator {
|
|
||||||
type Error = CE;
|
|
||||||
|
|
||||||
/// The collection the `StoreId` should be created for
|
|
||||||
fn collection() -> &'static str {
|
|
||||||
"contact"
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A function which should generate a unique string for a Path
|
|
||||||
fn unique_hash<A: AsRef<Path>>(path: A) -> RResult<String, Self::Error> {
|
|
||||||
use vobject::vcard::Vcard;
|
|
||||||
|
|
||||||
debug!("Generating unique hash for path: {:?}", path.as_ref());
|
|
||||||
util::read_to_string(path.as_ref())
|
|
||||||
.and_then(|s| Vcard::build(&s).map_err(CE::from))
|
|
||||||
.and_then(|card| {
|
|
||||||
card.uid()
|
|
||||||
.map(|u| u.raw().clone())
|
|
||||||
.ok_or_else(|| {
|
|
||||||
let s = path.as_ref().to_str().unwrap_or("Unknown path");
|
|
||||||
CEK::UidMissing(String::from(s)).into()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ContactStore<'a> : RefStore<'a> {
|
|
||||||
|
|
||||||
// creating
|
// creating
|
||||||
|
|
||||||
fn create_from_path(&'a self, p: &PathBuf) -> Result<FileLockEntry<'a>>;
|
fn create_from_path(&'a self, p: &PathBuf) -> Result<FileLockEntry<'a>>;
|
||||||
|
|
||||||
/// Create contact ref from buffer
|
/// Create contact ref from buffer
|
||||||
///
|
fn create_from_buf(&'a self, buf: &String) -> Result<FileLockEntry<'a>>;
|
||||||
/// Needs the `p` argument as we're finally creating a reference by path, the buffer is only for
|
|
||||||
/// collecting metadata.
|
|
||||||
fn create_from_buf<P: AsRef<Path>>(&'a self, p: P, buf: &String) -> Result<FileLockEntry<'a>>;
|
|
||||||
|
|
||||||
// getting
|
// getting
|
||||||
|
|
||||||
|
@ -82,30 +49,18 @@ pub trait ContactStore<'a> : RefStore<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The extension for the Store to work with contacts
|
/// The extension for the Store to work with contacts
|
||||||
///
|
|
||||||
/// The contact functionality is implemented by using the `libimagentryref` library, so basically
|
|
||||||
/// we only reference vcard files from outside the store.
|
|
||||||
///
|
|
||||||
/// Because of this, we do not have an own store collection `/contacts` or something like that, but
|
|
||||||
/// must stress the `libimagentryref` API for everything.
|
|
||||||
impl<'a> ContactStore<'a> for Store {
|
impl<'a> ContactStore<'a> for Store {
|
||||||
|
|
||||||
fn create_from_path(&'a self, p: &PathBuf) -> Result<FileLockEntry<'a>> {
|
fn create_from_path(&'a self, p: &PathBuf) -> Result<FileLockEntry<'a>> {
|
||||||
util::read_to_string(p).and_then(|buf| self.create_from_buf(p, &buf))
|
util::read_to_string(p).and_then(|buf| self.create_from_buf(&buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create contact ref from buffer
|
/// Create contact ref from buffer
|
||||||
fn create_from_buf<P: AsRef<Path>>(&'a self, p: P, buf: &String) -> Result<FileLockEntry<'a>> {
|
fn create_from_buf(&'a self, buf: &String) -> Result<FileLockEntry<'a>> {
|
||||||
let component = parse_component(&buf)?;
|
let component = parse_component(&buf)?;
|
||||||
debug!("Parsed: {:?}", component);
|
debug!("Parsed: {:?}", component);
|
||||||
|
|
||||||
RefStore::create_ref::<UniqueContactPathGenerator, P>(self, p)
|
unimplemented!()
|
||||||
.map_err(From::from)
|
|
||||||
.and_then(|mut entry| {
|
|
||||||
entry.set_isflag::<IsContact>()
|
|
||||||
.map_err(From::from)
|
|
||||||
.map(|_| entry)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn all_contacts(&'a self) -> Result<StoreIdIterator> {
|
fn all_contacts(&'a self) -> Result<StoreIdIterator> {
|
||||||
|
|
Loading…
Reference in a new issue