lib: rename contacts into contacts-cache
Plus dependents.
This commit is contained in:
172
lib/Makefile.am
172
lib/Makefile.am
@ -20,116 +20,116 @@ include $(top_srcdir)/gtest.mk
|
|||||||
|
|
||||||
SUBDIRS= utils index
|
SUBDIRS= utils index
|
||||||
|
|
||||||
TESTDEFS= \
|
TESTDEFS= \
|
||||||
-DMU_TESTMAILDIR=\"${abs_srcdir}/testdir\" \
|
-DMU_TESTMAILDIR=\"${abs_srcdir}/testdir\" \
|
||||||
-DMU_TESTMAILDIR2=\"${abs_srcdir}/testdir2\" \
|
-DMU_TESTMAILDIR2=\"${abs_srcdir}/testdir2\" \
|
||||||
-DMU_TESTMAILDIR4=\"${abs_srcdir}/testdir4\" \
|
-DMU_TESTMAILDIR4=\"${abs_srcdir}/testdir4\" \
|
||||||
-DABS_CURDIR=\"${abs_builddir}\" \
|
-DABS_CURDIR=\"${abs_builddir}\" \
|
||||||
-DABS_SRCDIR=\"${abs_srcdir}\"
|
-DABS_SRCDIR=\"${abs_srcdir}\"
|
||||||
|
|
||||||
|
|
||||||
AM_CFLAGS= \
|
AM_CFLAGS= \
|
||||||
$(WARN_CFLAGS) \
|
$(WARN_CFLAGS) \
|
||||||
$(GMIME_CFLAGS) \
|
$(GMIME_CFLAGS) \
|
||||||
$(XAPIAN_CFLAGS) \
|
$(XAPIAN_CFLAGS) \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
$(GUILE_CFLAGS) \
|
$(GUILE_CFLAGS) \
|
||||||
$(ASAN_CFLAGS) \
|
$(ASAN_CFLAGS) \
|
||||||
$(CODE_COVERAGE_CFLAGS) \
|
$(CODE_COVERAGE_CFLAGS) \
|
||||||
$(TESTDEFS) \
|
$(TESTDEFS) \
|
||||||
-Wno-format-nonliteral \
|
-Wno-format-nonliteral \
|
||||||
-Wno-switch-enum \
|
-Wno-switch-enum \
|
||||||
-Wno-deprecated-declarations \
|
-Wno-deprecated-declarations \
|
||||||
-Wno-inline
|
-Wno-inline
|
||||||
|
|
||||||
AM_CXXFLAGS= \
|
AM_CXXFLAGS= \
|
||||||
$(GMIME_CFLAGS) \
|
$(GMIME_CFLAGS) \
|
||||||
$(GLIB_CFLAGS) \
|
$(GLIB_CFLAGS) \
|
||||||
$(GUILE_CFLAGS) \
|
$(GUILE_CFLAGS) \
|
||||||
$(WARN_CXXFLAGS) \
|
$(WARN_CXXFLAGS) \
|
||||||
$(XAPIAN_CXXFLAGS) \
|
$(XAPIAN_CXXFLAGS) \
|
||||||
$(ASAN_CXXFLAGS) \
|
$(ASAN_CXXFLAGS) \
|
||||||
$(CODE_COVERAGE_CFLAGS) \
|
$(CODE_COVERAGE_CFLAGS) \
|
||||||
$(TESTDEFS)
|
$(TESTDEFS)
|
||||||
|
|
||||||
AM_CPPFLAGS= \
|
AM_CPPFLAGS= \
|
||||||
$(CODE_COVERAGE_CPPFLAGS)
|
$(CODE_COVERAGE_CPPFLAGS)
|
||||||
|
|
||||||
noinst_LTLIBRARIES= \
|
noinst_LTLIBRARIES= \
|
||||||
libmu.la
|
libmu.la
|
||||||
|
|
||||||
libmu_la_SOURCES= \
|
libmu_la_SOURCES= \
|
||||||
mu-bookmarks.cc \
|
mu-bookmarks.cc \
|
||||||
mu-bookmarks.hh \
|
mu-bookmarks.hh \
|
||||||
mu-contacts.cc \
|
mu-contacts-cache.cc \
|
||||||
mu-contacts.hh \
|
mu-contacts-cache.hh \
|
||||||
mu-data.hh \
|
mu-data.hh \
|
||||||
mu-parser.cc \
|
mu-parser.cc \
|
||||||
mu-parser.hh \
|
mu-parser.hh \
|
||||||
mu-query.cc \
|
mu-query.cc \
|
||||||
mu-query.hh \
|
mu-query.hh \
|
||||||
mu-query-results.hh \
|
mu-query-results.hh \
|
||||||
mu-query-match-deciders.cc \
|
mu-query-match-deciders.cc \
|
||||||
mu-query-match-deciders.hh \
|
mu-query-match-deciders.hh \
|
||||||
mu-query-threads.cc \
|
mu-query-threads.cc \
|
||||||
mu-query-threads.hh \
|
mu-query-threads.hh \
|
||||||
mu-runtime.cc \
|
mu-runtime.cc \
|
||||||
mu-runtime.hh \
|
mu-runtime.hh \
|
||||||
mu-script.cc \
|
mu-script.cc \
|
||||||
mu-script.hh \
|
mu-script.hh \
|
||||||
mu-server.cc \
|
mu-server.cc \
|
||||||
mu-server.hh \
|
mu-server.hh \
|
||||||
mu-store.cc \
|
mu-store.cc \
|
||||||
mu-store.hh \
|
mu-store.hh \
|
||||||
mu-tokenizer.cc \
|
mu-tokenizer.cc \
|
||||||
mu-tokenizer.hh \
|
mu-tokenizer.hh \
|
||||||
mu-tree.hh \
|
mu-tree.hh \
|
||||||
mu-xapian.cc \
|
mu-xapian.cc \
|
||||||
mu-xapian.hh \
|
mu-xapian.hh \
|
||||||
mu-maildir.cc \
|
mu-maildir.cc \
|
||||||
mu-maildir.hh \
|
mu-maildir.hh \
|
||||||
mu-msg-crypto.cc \
|
mu-msg-crypto.cc \
|
||||||
mu-msg-doc.cc \
|
mu-msg-doc.cc \
|
||||||
mu-msg-doc.hh \
|
mu-msg-doc.hh \
|
||||||
mu-msg-fields.c \
|
mu-msg-fields.c \
|
||||||
mu-msg-fields.h \
|
mu-msg-fields.h \
|
||||||
mu-msg-file.cc \
|
mu-msg-file.cc \
|
||||||
mu-msg-file.hh \
|
mu-msg-file.hh \
|
||||||
mu-msg-part.cc \
|
mu-msg-part.cc \
|
||||||
mu-msg-part.hh \
|
mu-msg-part.hh \
|
||||||
mu-msg-priv.hh \
|
mu-msg-priv.hh \
|
||||||
mu-msg-sexp.cc \
|
mu-msg-sexp.cc \
|
||||||
mu-msg.cc \
|
mu-msg.cc \
|
||||||
mu-msg.hh \
|
mu-msg.hh \
|
||||||
mu-message-flags.hh \
|
mu-message-flags.hh \
|
||||||
mu-message-flags.cc \
|
mu-message-flags.cc \
|
||||||
mu-message-priority.hh \
|
mu-message-priority.hh \
|
||||||
mu-message-priority.cc
|
mu-message-priority.cc
|
||||||
|
|
||||||
|
|
||||||
libmu_la_LIBADD= \
|
libmu_la_LIBADD= \
|
||||||
$(XAPIAN_LIBS) \
|
$(XAPIAN_LIBS) \
|
||||||
$(GMIME_LIBS) \
|
$(GMIME_LIBS) \
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(GUILE_LIBS) \
|
$(GUILE_LIBS) \
|
||||||
${builddir}/index/libmu-index.la \
|
${builddir}/index/libmu-index.la \
|
||||||
$(CODE_COVERAGE_LIBS)
|
$(CODE_COVERAGE_LIBS)
|
||||||
|
|
||||||
libmu_la_LDFLAGS= \
|
libmu_la_LDFLAGS= \
|
||||||
$(ASAN_LDFLAGS)
|
$(ASAN_LDFLAGS)
|
||||||
|
|
||||||
noinst_PROGRAMS= \
|
noinst_PROGRAMS= \
|
||||||
tokenize
|
tokenize
|
||||||
|
|
||||||
tokenize_SOURCES= \
|
tokenize_SOURCES= \
|
||||||
tokenize.cc
|
tokenize.cc
|
||||||
|
|
||||||
tokenize_LDADD= \
|
tokenize_LDADD= \
|
||||||
$(WARN_LDFLAGS) \
|
$(WARN_LDFLAGS) \
|
||||||
libmu.la \
|
libmu.la \
|
||||||
utils/libmu-utils.la
|
utils/libmu-utils.la
|
||||||
|
|
||||||
EXTRA_DIST= \
|
EXTRA_DIST= \
|
||||||
doxyfile.in
|
doxyfile.in
|
||||||
|
|
||||||
CLEANFILES=*.log *.trs *core* *vgdump* *.gcda *.gcno
|
CLEANFILES=*.log *.trs *core* *vgdump* *.gcda *.gcno
|
||||||
|
|||||||
@ -23,8 +23,8 @@ lib_mu=static_library(
|
|||||||
[
|
[
|
||||||
'mu-bookmarks.cc',
|
'mu-bookmarks.cc',
|
||||||
'mu-bookmarks.hh',
|
'mu-bookmarks.hh',
|
||||||
'mu-contacts.cc',
|
'mu-contacts-cache.cc',
|
||||||
'mu-contacts.hh',
|
'mu-contacts-cache.hh',
|
||||||
'mu-data.hh',
|
'mu-data.hh',
|
||||||
'mu-parser.cc',
|
'mu-parser.cc',
|
||||||
'mu-parser.hh',
|
'mu-parser.hh',
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mu-contacts.hh"
|
#include "mu-contacts-cache.hh"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -105,7 +105,7 @@ using ContactUMap = std::unordered_map<const std::string, ContactInfo, EmailHash
|
|||||||
// using ContactUSet = std::unordered_set<ContactInfo, ContactInfoHash, ContactInfoEqual>;
|
// using ContactUSet = std::unordered_set<ContactInfo, ContactInfoHash, ContactInfoEqual>;
|
||||||
using ContactSet = std::set<std::reference_wrapper<const ContactInfo>, ContactInfoLessThan>;
|
using ContactSet = std::set<std::reference_wrapper<const ContactInfo>, ContactInfoLessThan>;
|
||||||
|
|
||||||
struct Contacts::Private {
|
struct ContactsCache::Private {
|
||||||
Private(const std::string& serialized, const StringVec& personal)
|
Private(const std::string& serialized, const StringVec& personal)
|
||||||
: contacts_{deserialize(serialized)}, dirty_{0}
|
: contacts_{deserialize(serialized)}, dirty_{0}
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ struct Contacts::Private {
|
|||||||
constexpr auto Separator = "\xff"; // Invalid in UTF-8
|
constexpr auto Separator = "\xff"; // Invalid in UTF-8
|
||||||
|
|
||||||
void
|
void
|
||||||
Contacts::Private::make_personal(const StringVec& personal)
|
ContactsCache::Private::make_personal(const StringVec& personal)
|
||||||
{
|
{
|
||||||
for (auto&& p : personal) {
|
for (auto&& p : personal) {
|
||||||
if (p.empty())
|
if (p.empty())
|
||||||
@ -154,7 +154,7 @@ Contacts::Private::make_personal(const StringVec& personal)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ContactUMap
|
ContactUMap
|
||||||
Contacts::Private::deserialize(const std::string& serialized) const
|
ContactsCache::Private::deserialize(const std::string& serialized) const
|
||||||
{
|
{
|
||||||
ContactUMap contacts;
|
ContactUMap contacts;
|
||||||
std::stringstream ss{serialized, std::ios_base::in};
|
std::stringstream ss{serialized, std::ios_base::in};
|
||||||
@ -180,14 +180,14 @@ Contacts::Private::deserialize(const std::string& serialized) const
|
|||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Contacts::Contacts(const std::string& serialized, const StringVec& personal)
|
ContactsCache::ContactsCache(const std::string& serialized, const StringVec& personal)
|
||||||
: priv_{std::make_unique<Private>(serialized, personal)}
|
: priv_{std::make_unique<Private>(serialized, personal)}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Contacts::~Contacts() = default;
|
ContactsCache::~ContactsCache() = default;
|
||||||
std::string
|
std::string
|
||||||
Contacts::serialize() const
|
ContactsCache::serialize() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
||||||
std::string s;
|
std::string s;
|
||||||
@ -219,13 +219,13 @@ Contacts::serialize() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Contacts::dirty() const
|
ContactsCache::dirty() const
|
||||||
{
|
{
|
||||||
return priv_->dirty_;
|
return priv_->dirty_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ContactInfo
|
const ContactInfo
|
||||||
Contacts::add(ContactInfo&& ci)
|
ContactsCache::add(ContactInfo&& ci)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ Contacts::add(ContactInfo&& ci)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ContactInfo*
|
const ContactInfo*
|
||||||
Contacts::_find(const std::string& email) const
|
ContactsCache::_find(const std::string& email) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
||||||
|
|
||||||
@ -273,7 +273,7 @@ Contacts::_find(const std::string& email) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Contacts::clear()
|
ContactsCache::clear()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ Contacts::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
Contacts::size() const
|
ContactsCache::size() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ Contacts::size() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Contacts::for_each(const EachContactFunc& each_contact) const
|
ContactsCache::for_each(const EachContactFunc& each_contact) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
std::lock_guard<std::mutex> l_{priv_->mtx_};
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ Contacts::for_each(const EachContactFunc& each_contact) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Contacts::is_personal(const std::string& addr) const
|
ContactsCache::is_personal(const std::string& addr) const
|
||||||
{
|
{
|
||||||
for (auto&& p : priv_->personal_plain_)
|
for (auto&& p : priv_->personal_plain_)
|
||||||
if (g_ascii_strcasecmp(addr.c_str(), p.c_str()) == 0)
|
if (g_ascii_strcasecmp(addr.c_str(), p.c_str()) == 0)
|
||||||
@ -334,7 +334,7 @@ Contacts::is_personal(const std::string& addr) const
|
|||||||
static void
|
static void
|
||||||
test_mu_contacts_01()
|
test_mu_contacts_01()
|
||||||
{
|
{
|
||||||
Mu::Contacts contacts("");
|
Mu::ContactsCache contacts("");
|
||||||
|
|
||||||
g_assert_true(contacts.empty());
|
g_assert_true(contacts.empty());
|
||||||
g_assert_cmpuint(contacts.size(), ==, 0);
|
g_assert_cmpuint(contacts.size(), ==, 0);
|
||||||
@ -385,7 +385,7 @@ static void
|
|||||||
test_mu_contacts_02()
|
test_mu_contacts_02()
|
||||||
{
|
{
|
||||||
Mu::StringVec personal = {"foo@example.com", "bar@cuux.org", "/bar-.*@fnorb.f./"};
|
Mu::StringVec personal = {"foo@example.com", "bar@cuux.org", "/bar-.*@fnorb.f./"};
|
||||||
Mu::Contacts contacts{"", personal};
|
Mu::ContactsCache contacts{"", personal};
|
||||||
|
|
||||||
g_assert_true(contacts.is_personal("foo@example.com"));
|
g_assert_true(contacts.is_personal("foo@example.com"));
|
||||||
g_assert_true(contacts.is_personal("Bar@CuuX.orG"));
|
g_assert_true(contacts.is_personal("Bar@CuuX.orG"));
|
||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2020-2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
@ -17,8 +17,8 @@
|
|||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __MU_CONTACTS_HH__
|
#ifndef __MU_CONTACTS_CACHE_HH__
|
||||||
#define __MU_CONTACTS_HH__
|
#define __MU_CONTACTS_CACHE_HH__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@ -62,22 +62,21 @@ struct ContactInfo {
|
|||||||
int64_t tstamp{}; /**< Time-stamp, as per g_get_monotonic_time */
|
int64_t tstamp{}; /**< Time-stamp, as per g_get_monotonic_time */
|
||||||
};
|
};
|
||||||
|
|
||||||
/// All contacts
|
class ContactsCache {
|
||||||
class Contacts {
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Construct a new contacts objects
|
* Construct a new ContactsCache object
|
||||||
*
|
*
|
||||||
* @param serialized serialized contacts
|
* @param serialized serialized contacts
|
||||||
* @param personal personal addresses
|
* @param personal personal addresses
|
||||||
*/
|
*/
|
||||||
Contacts(const std::string& serialized = "", const StringVec& personal = {});
|
ContactsCache(const std::string& serialized = "", const StringVec& personal = {});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTOR
|
* DTOR
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
~Contacts();
|
~ContactsCache();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a contact
|
* Add a contact
|
||||||
@ -166,4 +165,4 @@ private:
|
|||||||
|
|
||||||
} // namespace Mu
|
} // namespace Mu
|
||||||
|
|
||||||
#endif /* __MU_CONTACTS_HH__ */
|
#endif /* __MU_CONTACTS_CACHE_HH__ */
|
||||||
@ -42,7 +42,6 @@
|
|||||||
#include "index/mu-indexer.hh"
|
#include "index/mu-indexer.hh"
|
||||||
#include "mu-store.hh"
|
#include "mu-store.hh"
|
||||||
#include "mu-msg-part.hh"
|
#include "mu-msg-part.hh"
|
||||||
#include "mu-contacts.hh"
|
|
||||||
|
|
||||||
#include "utils/mu-str.h"
|
#include "utils/mu-str.h"
|
||||||
#include "utils/mu-utils.hh"
|
#include "utils/mu-utils.hh"
|
||||||
@ -523,7 +522,7 @@ Server::Private::contacts_handler(const Parameters& params)
|
|||||||
|
|
||||||
auto rank{0};
|
auto rank{0};
|
||||||
Sexp::List contacts;
|
Sexp::List contacts;
|
||||||
store().contacts().for_each([&](const ContactInfo& ci) {
|
store().contacts_cache().for_each([&](const ContactInfo& ci) {
|
||||||
rank++;
|
rank++;
|
||||||
|
|
||||||
/* since the last time we got some contacts */
|
/* since the last time we got some contacts */
|
||||||
|
|||||||
@ -118,7 +118,7 @@ struct Store::Private {
|
|||||||
: read_only_{readonly}, db_{make_xapian_db(path,
|
: read_only_{readonly}, db_{make_xapian_db(path,
|
||||||
read_only_ ? XapianOpts::ReadOnly
|
read_only_ ? XapianOpts::ReadOnly
|
||||||
: XapianOpts::Open)},
|
: XapianOpts::Open)},
|
||||||
properties_{make_properties(path)}, contacts_{db().get_metadata(ContactsKey),
|
properties_{make_properties(path)}, contacts_cache_{db().get_metadata(ContactsKey),
|
||||||
properties_.personal_addresses}
|
properties_.personal_addresses}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -129,7 +129,7 @@ struct Store::Private {
|
|||||||
const Store::Config& conf)
|
const Store::Config& conf)
|
||||||
: read_only_{false}, db_{make_xapian_db(path, XapianOpts::CreateOverwrite)},
|
: read_only_{false}, db_{make_xapian_db(path, XapianOpts::CreateOverwrite)},
|
||||||
properties_{init_metadata(conf, path, root_maildir, personal_addresses)},
|
properties_{init_metadata(conf, path, root_maildir, personal_addresses)},
|
||||||
contacts_{"", properties_.personal_addresses}
|
contacts_cache_{"", properties_.personal_addresses}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ struct Store::Private {
|
|||||||
const Store::Config& conf)
|
const Store::Config& conf)
|
||||||
: read_only_{false}, db_{make_xapian_db("", XapianOpts::InMemory)},
|
: read_only_{false}, db_{make_xapian_db("", XapianOpts::InMemory)},
|
||||||
properties_{init_metadata(conf, "", root_maildir, personal_addresses)},
|
properties_{init_metadata(conf, "", root_maildir, personal_addresses)},
|
||||||
contacts_{"", properties_.personal_addresses}
|
contacts_cache_{"", properties_.personal_addresses}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,10 +210,10 @@ struct Store::Private {
|
|||||||
return; // not supported or not in transaction
|
return; // not supported or not in transaction
|
||||||
|
|
||||||
if (force || transaction_size_ >= properties_.batch_size) {
|
if (force || transaction_size_ >= properties_.batch_size) {
|
||||||
if (contacts_.dirty()) {
|
if (contacts_cache_.dirty()) {
|
||||||
xapian_try([&] {
|
xapian_try([&] {
|
||||||
writable_db().set_metadata(ContactsKey,
|
writable_db().set_metadata(ContactsKey,
|
||||||
contacts_.serialize());
|
contacts_cache_.serialize());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
g_debug("committing transaction (n=%zu,%zu)",
|
g_debug("committing transaction (n=%zu,%zu)",
|
||||||
@ -310,7 +310,7 @@ struct Store::Private {
|
|||||||
std::unique_ptr<Xapian::Database> db_;
|
std::unique_ptr<Xapian::Database> db_;
|
||||||
|
|
||||||
const Store::Properties properties_;
|
const Store::Properties properties_;
|
||||||
Contacts contacts_;
|
ContactsCache contacts_cache_;
|
||||||
std::unique_ptr<Indexer> indexer_;
|
std::unique_ptr<Indexer> indexer_;
|
||||||
|
|
||||||
size_t transaction_size_{};
|
size_t transaction_size_{};
|
||||||
@ -365,10 +365,10 @@ Store::properties() const
|
|||||||
return priv_->properties_;
|
return priv_->properties_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Contacts&
|
const ContactsCache&
|
||||||
Store::contacts() const
|
Store::contacts_cache() const
|
||||||
{
|
{
|
||||||
return priv_->contacts_;
|
return priv_->contacts_cache_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Xapian::Database&
|
const Xapian::Database&
|
||||||
@ -980,7 +980,7 @@ xapian_pfx(const MessageContact& contact)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
add_contacts_terms_values(Xapian::Document& doc, MuMsg *msg,
|
add_contacts_terms_values(Xapian::Document& doc, MuMsg *msg,
|
||||||
Contacts& contacts_store)
|
ContactsCache& contacts_cache)
|
||||||
{
|
{
|
||||||
Xapian::TermGenerator termgen;
|
Xapian::TermGenerator termgen;
|
||||||
termgen.set_document(doc);
|
termgen.set_document(doc);
|
||||||
@ -1007,11 +1007,11 @@ add_contacts_terms_values(Xapian::Document& doc, MuMsg *msg,
|
|||||||
termgen.index_text_without_positions(contact.email, 1, pfx);
|
termgen.index_text_without_positions(contact.email, 1, pfx);
|
||||||
|
|
||||||
/* and add to the contact store.*/
|
/* and add to the contact store.*/
|
||||||
contacts_store.add(ContactInfo{
|
contacts_cache.add(ContactInfo{
|
||||||
contact.display_name(),
|
contact.display_name(),
|
||||||
contact.email,
|
contact.email,
|
||||||
contact.name,
|
contact.name,
|
||||||
contacts_store.is_personal(contact.email),
|
contacts_cache.is_personal(contact.email),
|
||||||
contact.message_date});
|
contact.message_date});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1022,7 +1022,7 @@ Store::Private::new_doc_from_message(MuMsg* msg)
|
|||||||
Xapian::Document doc;
|
Xapian::Document doc;
|
||||||
MsgDoc docinfo = {&doc, msg, this, 0, NULL};
|
MsgDoc docinfo = {&doc, msg, this, 0, NULL};
|
||||||
|
|
||||||
add_contacts_terms_values(doc, msg, contacts_);
|
add_contacts_terms_values(doc, msg, contacts_cache_);
|
||||||
mu_msg_field_foreach((MuMsgFieldForeachFunc)add_terms_values, &docinfo);
|
mu_msg_field_foreach((MuMsgFieldForeachFunc)add_terms_values, &docinfo);
|
||||||
// g_printerr ("\n--%s\n--\n", doc.serialise().c_str());
|
// g_printerr ("\n--%s\n--\n", doc.serialise().c_str());
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
@ -27,7 +27,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include "mu-contacts.hh"
|
#include "mu-contacts-cache.hh"
|
||||||
#include <xapian.h>
|
#include <xapian.h>
|
||||||
|
|
||||||
#include <utils/mu-utils.hh>
|
#include <utils/mu-utils.hh>
|
||||||
@ -111,11 +111,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
const Properties& properties() const;
|
const Properties& properties() const;
|
||||||
/**
|
/**
|
||||||
* Get the Contacts object for this store
|
* Get the ContactsCache object for this store
|
||||||
*
|
*
|
||||||
* @return the Contacts object
|
* @return the Contacts object
|
||||||
*/
|
*/
|
||||||
const Contacts& contacts() const;
|
const ContactsCache& contacts_cache() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the underlying Xapian database for this store.
|
* Get the underlying Xapian database for this store.
|
||||||
|
|||||||
@ -55,9 +55,9 @@ test('test_threads',
|
|||||||
install: false,
|
install: false,
|
||||||
cpp_args: ['-DBUILD_TESTS'],
|
cpp_args: ['-DBUILD_TESTS'],
|
||||||
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
|
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
|
||||||
test('test_contacts',
|
test('test_contacts-cache',
|
||||||
executable('test-contacts',
|
executable('test-contacts',
|
||||||
'../mu-contacts.cc',
|
'../mu-contacts-cache.cc',
|
||||||
install: false,
|
install: false,
|
||||||
cpp_args: ['-DBUILD_TESTS'],
|
cpp_args: ['-DBUILD_TESTS'],
|
||||||
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
|
dependencies: [glib_dep, lib_mu_dep, lib_test_mu_common_dep]))
|
||||||
@ -67,7 +67,8 @@ test('test_message_contact',
|
|||||||
'../mu-message-contact.cc',
|
'../mu-message-contact.cc',
|
||||||
install: false,
|
install: false,
|
||||||
cpp_args: ['-DBUILD_TESTS'],
|
cpp_args: ['-DBUILD_TESTS'],
|
||||||
dependencies: [glib_dep, gmime_dep, lib_mu_dep, lib_test_mu_common_dep]))
|
dependencies: [glib_dep, gmime_dep, lib_mu_dep,
|
||||||
|
lib_test_mu_common_dep]))
|
||||||
|
|
||||||
test('test_parser',
|
test('test_parser',
|
||||||
executable('test-parser',
|
executable('test-parser',
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "mu-cmd.hh"
|
#include "mu-cmd.hh"
|
||||||
#include "mu-contacts.hh"
|
#include "mu-contacts-cache.hh"
|
||||||
#include "mu-runtime.hh"
|
#include "mu-runtime.hh"
|
||||||
|
|
||||||
#include "utils/mu-util.h"
|
#include "utils/mu-util.h"
|
||||||
@ -363,7 +363,7 @@ run_cmd_cfind(const Mu::Store& store,
|
|||||||
|
|
||||||
print_header(format);
|
print_header(format);
|
||||||
|
|
||||||
store.contacts().for_each([&](const auto& ci) { each_contact(ci, ecdata); });
|
store.contacts_cache().for_each([&](const auto& ci) { each_contact(ci, ecdata); });
|
||||||
|
|
||||||
g_hash_table_unref(ecdata.nicks);
|
g_hash_table_unref(ecdata.nicks);
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
#include "mu-msg-part.hh"
|
#include "mu-msg-part.hh"
|
||||||
#include "mu-cmd.hh"
|
#include "mu-cmd.hh"
|
||||||
#include "mu-maildir.hh"
|
#include "mu-maildir.hh"
|
||||||
#include "mu-contacts.hh"
|
#include "mu-contacts-cache.hh"
|
||||||
#include "mu-runtime.hh"
|
#include "mu-runtime.hh"
|
||||||
#include "mu-message-flags.hh"
|
#include "mu-message-flags.hh"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user