32 auto storage = QASecret::KeyStorage::instance();
35 sendResuylt(QuasarAppUtils::Locales::tr(
"Service is stoped. Please use the start command."));
39 bool fAdd = data.contains(
"add");
40 bool fRemove = data.contains(
"remove");
41 bool fGet = data.contains(
"get");
43 int actionsCount = fAdd + fRemove + fGet;
44 if (actionsCount > 1) {
45 sendResuylt(QuasarAppUtils::Locales::tr(
"You are try to run multiple commands. please choose some of pleas choose one."));
47 }
else if (data.isEmpty()) {
48 sendResuylt(QuasarAppUtils::Locales::tr(
"please choose one of available actions add/remove/get"));
53 const auto&& dataVal = data.value(
"data").arg();
54 const auto&& aliasVal = data.value(
"alias").arg();
56 if (dataVal.isEmpty()) {
57 sendResuylt(QuasarAppUtils::Locales::tr(
"You forget a data. please use the next command add -data yourDataString"));
61 sendRawResuylt(storage->add(dataVal.toLatin1(), aliasVal));
65 const auto&& hashVal = data.value(
"hash").arg();
66 const auto&& aliasVal = data.value(
"alias").arg();
68 if (hashVal.isEmpty() && aliasVal.isEmpty()) {
69 sendResuylt(QuasarAppUtils::Locales::tr(
"You forget a hash key of alias of getting data. "
70 "Please use the next command get -hash yourHash or "
71 "get -alias yourAlias"));
76 sendRawResuylt(storage->get(hashVal.toLatin1()));
77 }
else if (aliasVal.size()) {
78 sendRawResuylt(storage->get(aliasVal));
83 const auto&& hashVal = data.value(
"hash").arg();
84 const auto&& aliasVal = data.value(
"alias").arg();
86 if (hashVal.isEmpty() && aliasVal.isEmpty()) {
87 sendResuylt(QuasarAppUtils::Locales::tr(
"You forget a hash key of alias of removable data. "
88 "Please use the next command remove -hash yourHash or "
89 "remove -alias yourAlias"));
94 storage->remove(hashVal.toLatin1());
95 }
else if (aliasVal.size()) {
96 storage->remove(aliasVal);
100 Patronum::Service<QCoreApplication>::handleReceiveData(data);
122 QSet<Patronum::Feature> data;
124 data << Patronum::Feature(
"ping", {}, QuasarAppUtils::Locales::tr(
"This is description of the ping command"));
125 data << Patronum::Feature(
"state", {}, QuasarAppUtils::Locales::tr(
"Returns state"));
126 data << Patronum::Feature(
"add",
128 QuasarAppUtils::Locales::tr(
"Adds new value into seret storage, and return a hash key after adding."),
129 "QASecret add -data mysecretString -alias myCustomKey ");
130 data << Patronum::Feature(
"remove",
132 QuasarAppUtils::Locales::tr(
"Remove data from storage by hash key or alias."),
133 "QASecret remove -hash hashKey or QASecret remove -alias myCustomKey");
134 data << Patronum::Feature(
"get",
136 QuasarAppUtils::Locales::tr(
"return secret from database"),
137 "QASecret get -hash hashKey or QASecret get -alias myCustomKey ");
138 data << Patronum::Feature(
"-alias", {
"aliasName"}, QuasarAppUtils::Locales::tr(
"Alias name"));
139 data << Patronum::Feature(
"-data", {
"data"}, QuasarAppUtils::Locales::tr(
"Data that will be saved"));
140 data << Patronum::Feature(
"-hash", {
"hash"}, QuasarAppUtils::Locales::tr(
"Hash kay of data"));