summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-04-30 09:12:40 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-04-30 09:12:40 +0200
commit1f3b133321a71fa32556fb6d9e6611967c381ff0 (patch)
tree3b726f8b37a1ec4489d045e2ce3009cabe2a4844 /src
parentda522ec13bf26defffddfa8ef0c20cc2b3fd0845 (diff)
Test: device and owner identity updates after discovery
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d403d29..84dfe2a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -229,6 +229,23 @@ void watchSharedIdentity(const vector<string> &)
});
}
+void updateLocalIdentity(const vector<string> & params)
+{
+ if (params.size() != 1) {
+ throw invalid_argument("usage: update-local-identity <name>");
+ }
+
+ auto nh = h->update([&params] (const Stored<LocalState> & loc) {
+ auto st = loc.ref().storage();
+
+ auto b = loc->identity()->modify();
+ b.name(params[0]);
+ return st.store(loc->identity(b.commit()));
+ });
+ if (nh)
+ *h = *nh;
+}
+
void updateSharedIdentity(const vector<string> & params)
{
if (params.size() != 1) {
@@ -270,6 +287,7 @@ vector<Command> commands = {
{ "stop-server", stopServer },
{ "watch-local-identity", watchLocalIdentity },
{ "watch-shared-identity", watchSharedIdentity },
+ { "update-local-identity", updateLocalIdentity },
{ "update-shared-identity", updateSharedIdentity },
{ "attach-to", attachTo },
{ "attach-accept", attachAccept },