Update to use Libraries and fix include order

This commit is contained in:
2020-03-07 14:46:26 +01:00
parent 3b7491f57d
commit 157b1ceb51
32 changed files with 114 additions and 1405 deletions
+16 -13
View File
@@ -1,8 +1,8 @@
#include "Device.h"
#include "Util/JSON.h"
#include <Logging.h>
#include <algorithm>
#include <sstream>
#include "Util/JSON.h"
#include "Util/Logger.h"
#include "Device.h"
namespace PresenceDetection {
@@ -63,8 +63,11 @@ bool Device::Login()
try
{
std::vector<std::string> headers;
headers.push_back("Content-Type: application/json");
std::stringstream output;
output << m_httpClient.GetUrlPostContents(url.str(), m_cookieFile, json.dump(), "application/json");
output << m_httpClient.GetUrlPostContents(url.str(), headers, m_cookieFile, json.dump());
Util::JSON outputJSON = Util::JSON::parse(output);
@@ -79,7 +82,7 @@ bool Device::Login()
{
std::stringstream ss;
ss << "UniFi::Device::Login() - Error: " << e.what() << std::endl;
Util::Logger::Log(Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
std::lock_guard<std::mutex> lock(m_mutex);
m_loggedIn = false;
return m_loggedIn;
@@ -106,7 +109,7 @@ void Device::Logout()
{
std::stringstream ss;
ss << "UniFi::Device::Logout() - Error: " << e.what() << std::endl;
Util::Logger::Log(Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
}
}
@@ -122,7 +125,7 @@ void Device::ClearDevices()
{
std::stringstream ss;
ss << "UniFi::Device::ClearDevices() - Error: " << e.what() << std::endl;
Util::Logger::Log(Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
}
}
@@ -138,7 +141,7 @@ void Device::ClearDevices()
{
std::stringstream ss;
ss << "UniFi::Device::ClearDevices() - Error: " << e.what() << std::endl;
Util::Logger::Log(Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
}
}
}
@@ -164,7 +167,7 @@ void Device::UpdateDevicesFromInventory()
{
std::stringstream ss;
ss << "UniFi::Device::GetDevicesFromInventory() - Error: " << e.what() << std::endl;
Util::Logger::Log(Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
}
}
@@ -236,7 +239,7 @@ void Device::UpdatePresentDevices()
{
std::stringstream ss;
ss << "UniFi::Device::IsDevicePresent() - Error: " << e.what() << std::endl;
Util::Logger::Log(Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
Logout();
return;
}
@@ -264,7 +267,7 @@ void Device::SendStateChange(bool present, const std::string& macAddress)
std::stringstream ss;
ss << "UniFi: " << sign << " " << macAddress;
Util::Logger::Log(Util::Logger::Severity::Info, ss.str());
Logging::Log(Logging::Severity::Info, ss.str());
if (!m_target.empty())
{
@@ -279,7 +282,7 @@ void Device::SendStateChange(bool present, const std::string& macAddress)
{
std::stringstream ss;
ss << "UniFi::Device::SendStateChange() - Error: " << e.what() << std::endl;
Util::Logger::Log(Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
}
}
@@ -316,7 +319,7 @@ void Device::SendStateChange(bool present, const std::string& macAddress)
{
std::stringstream ss;
ss << "UniFi::Device::SendStateChange() - Error: " << e.what() << std::endl;
Util::Logger::Log(Util::Logger::Severity::Error, ss.str());
Logging::Log(Logging::Severity::Error, ss.str());
}
}
}