summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2025-08-23 09:16:02 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2025-08-24 11:54:08 +0300
commit02a0dc4333d70b8793d5ac2b7a7557c6f7251c4f (patch)
tree20e6dbdf1daecf744ca43fdf41ae89ae1bcf9215 /lib
parent9a2d481fc397d1314d7bb6573f8727ef8c567c0f (diff)
mu-server: implement exposing the socket-path
Add the scm-socket-path to the ping-properties we expose for mu4e.
Diffstat (limited to 'lib')
-rw-r--r--lib/mu-server.cc38
-rw-r--r--lib/mu-server.hh1
2 files changed, 26 insertions, 13 deletions
diff --git a/lib/mu-server.cc b/lib/mu-server.cc
index 13fb63c..20bdc97 100644
--- a/lib/mu-server.cc
+++ b/lib/mu-server.cc
@@ -132,7 +132,8 @@ struct Server::Private {
{}
~Private() {
- indexer().stop();
+ if (have_indexer_)
+ indexer().stop();
if (!tmp_dir_.empty())
remove_directory(tmp_dir_);
}
@@ -145,7 +146,7 @@ struct Server::Private {
// acccessors
Store& store() { 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);
//CommandMap& command_map() const { return command_map_; }
@@ -212,6 +213,8 @@ private:
const CommandHandler command_handler_;
std::atomic<bool> keep_going_{};
std::string tmp_dir_;
+
+ bool have_indexer_{};
};
static void
@@ -1021,15 +1024,19 @@ Server::Private::ping_handler(const Command& cmd)
for (auto&& addr : store().config().get<Config::Id::PersonalAddresses>())
addrs.add(addr);
- output_sexp(Sexp()
- .put_props(":pong", "mu")
- .put_props(":props",
- Sexp().put_props(
- ":version", VERSION,
- ":personal-addresses", std::move(addrs),
- ":database-path", store().path(),
- ":root-maildir", store().root_maildir(),
- ":doccount", storecount)));
+ Sexp props = Sexp().put_props(
+ ":version", VERSION,
+ ":personal-addresses", std::move(addrs),
+ ":database-path", store().path(),
+ ":root-maildir", store().root_maildir(),
+ ":doccount", storecount);
+
+ if (!options_.socket_path.empty())
+ props.put_props(
+ ":scm-socket-path", options_.socket_path);
+
+ output_sexp(Sexp().put_props(":pong", "mu")
+ .put_props(":props", std::move(props)));
}
void
@@ -1107,7 +1114,9 @@ Server::Private::view_mark_as_read(Store::Id docid, Message&& msg, bool rename)
if (rename)
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))
output(mu_format("({} {})", id == docid ? ":view" : ":update",
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)
: priv_{std::make_unique<Private>(store, opts, output)}
-{}
+{
+ mu_message("created server with store @ {}; maildir @ {}",
+ store.path(), store.root_maildir());
+}
Server::~Server() = default;
diff --git a/lib/mu-server.hh b/lib/mu-server.hh
index 0ceaa68..79f18d0 100644
--- a/lib/mu-server.hh
+++ b/lib/mu-server.hh
@@ -51,6 +51,7 @@ public:
struct Options {
bool allow_temp_file; /**< temp file optimization allowed? */
+ std::string socket_path; /**< Socket path or empty */
};
/**