mu-server: implement exposing the socket-path

Add the scm-socket-path to the ping-properties we expose for mu4e.
This commit is contained in:
Dirk-Jan C. Binnema
2025-08-23 09:16:02 +03:00
parent 9a2d481fc3
commit 02a0dc4333
2 changed files with 26 additions and 13 deletions

View File

@ -132,7 +132,8 @@ struct Server::Private {
{} {}
~Private() { ~Private() {
indexer().stop(); if (have_indexer_)
indexer().stop();
if (!tmp_dir_.empty()) if (!tmp_dir_.empty())
remove_directory(tmp_dir_); remove_directory(tmp_dir_);
} }
@ -145,7 +146,7 @@ struct Server::Private {
// acccessors // acccessors
Store& store() { return store_; } Store& store() { return store_; }
const Store& store() const { return store_; } const Store& store() const { return store_; }
Indexer& indexer() { return store().indexer(); } Indexer& indexer() { have_indexer_ = true; return store().indexer(); }
void do_index(const Indexer::Config& conf); void do_index(const Indexer::Config& conf);
//CommandMap& command_map() const { return command_map_; } //CommandMap& command_map() const { return command_map_; }
@ -212,6 +213,8 @@ private:
const CommandHandler command_handler_; const CommandHandler command_handler_;
std::atomic<bool> keep_going_{}; std::atomic<bool> keep_going_{};
std::string tmp_dir_; std::string tmp_dir_;
bool have_indexer_{};
}; };
static void static void
@ -1021,15 +1024,19 @@ Server::Private::ping_handler(const Command& cmd)
for (auto&& addr : store().config().get<Config::Id::PersonalAddresses>()) for (auto&& addr : store().config().get<Config::Id::PersonalAddresses>())
addrs.add(addr); addrs.add(addr);
output_sexp(Sexp() Sexp props = Sexp().put_props(
.put_props(":pong", "mu") ":version", VERSION,
.put_props(":props", ":personal-addresses", std::move(addrs),
Sexp().put_props( ":database-path", store().path(),
":version", VERSION, ":root-maildir", store().root_maildir(),
":personal-addresses", std::move(addrs), ":doccount", storecount);
":database-path", store().path(),
":root-maildir", store().root_maildir(), if (!options_.socket_path.empty())
":doccount", storecount))); props.put_props(
":scm-socket-path", options_.socket_path);
output_sexp(Sexp().put_props(":pong", "mu")
.put_props(":props", std::move(props)));
} }
void void
@ -1107,7 +1114,9 @@ Server::Private::view_mark_as_read(Store::Id docid, Message&& msg, bool rename)
if (rename) if (rename)
move_opts |= Store::MoveOptions::ChangeName; move_opts |= Store::MoveOptions::ChangeName;
const auto ids{Store::id_vec(unwrap(store().move_message(docid, {}, nflags, move_opts)))}; const auto ids{Store::id_vec(
unwrap(store().move_message(docid, {},
nflags, move_opts)))};
for (auto&& [id, moved_msg]: store().find_messages(ids)) for (auto&& [id, moved_msg]: store().find_messages(ids))
output(mu_format("({} {})", id == docid ? ":view" : ":update", output(mu_format("({} {})", id == docid ? ":view" : ":update",
msg_sexp_str(moved_msg, id, {}))); msg_sexp_str(moved_msg, id, {})));
@ -1142,7 +1151,10 @@ Server::Private::view_handler(const Command& cmd)
Server::Server(Store& store, const Server::Options& opts, Server::Output output) Server::Server(Store& store, const Server::Options& opts, Server::Output output)
: priv_{std::make_unique<Private>(store, opts, output)} : priv_{std::make_unique<Private>(store, opts, output)}
{} {
mu_message("created server with store @ {}; maildir @ {}",
store.path(), store.root_maildir());
}
Server::~Server() = default; Server::~Server() = default;

View File

@ -51,6 +51,7 @@ public:
struct Options { struct Options {
bool allow_temp_file; /**< temp file optimization allowed? */ bool allow_temp_file; /**< temp file optimization allowed? */
std::string socket_path; /**< Socket path or empty */
}; };
/** /**