extra layer for device, more abstraction

This commit is contained in:
John
2023-06-16 20:26:30 +02:00
parent 9d08eec68e
commit 0ede430ece
5 changed files with 228 additions and 126 deletions
+3 -31
View File
@@ -372,12 +372,7 @@ void MainLoop::run() {
<< ",\"a\":\"other\""
#endif
<< ",\"u\":" << (now-start);
if (m_device->isEnhancedProto()) {
string ver = m_device->getEnhancedVersion();
if (!ver.empty()) {
ostr << ",\"dv\":\"" << ver << "\"";
}
}
m_device->formatInfo(&ostr, false, true, true);
if (m_reconnectCount) {
ostr << ",\"rc\":" << m_reconnectCount;
}
@@ -1944,31 +1939,8 @@ result_t MainLoop::executeInfo(const vector<string>& args, const string& user, o
if (!m_updateCheck.empty()) {
*ostream << "update check: " << m_updateCheck << "\n";
}
*ostream << "device: " << m_device->getName();
if (m_device->isEnhancedProto()) {
*ostream << ", enhanced";
}
if (m_device->isReadOnly()) {
*ostream << ", readonly";
}
if (!m_device->isValid()) {
*ostream << ", invalid";
}
bool infoAdded = false;
if (verbose) {
string info = m_device->getEnhancedInfos();
if (!info.empty()) {
*ostream << ", " << info;
infoAdded = true;
}
}
if (!infoAdded) {
string info = m_device->getEnhancedVersion();
if (!info.empty()) {
*ostream << ", firmware " << info;
}
}
*ostream << "device: ";
m_device->formatInfo(ostream, verbose);
*ostream << "\n";
if (!user.empty()) {
*ostream << "user: " << user << "\n";