Commit 11b4d82f authored by Łukasz Matysiak's avatar Łukasz Matysiak

Move printDeviceDetails to Printer

parent fb57d5e6
......@@ -186,30 +186,6 @@ std::vector<std::string> Mhwd::checkEnvironment() const
return missingDirs;
}
void Mhwd::printDeviceDetails(std::string type, FILE *f)
{
hw_item hw;
if ("USB" == type)
{
hw = hw_usb;
}
else
{
hw = hw_pci;
}
std::unique_ptr<hd_data_t> hd_data{new hd_data_t()};
hd_t *hd = hd_list(hd_data.get(), hw, 1, nullptr);
for (hd_t* hdIter = hd; hdIter; hdIter = hdIter->next)
{
hd_dump_entry(hd_data.get(), hdIter, f);
}
hd_free_hd_list(hd);
hd_free_hd_data(hd_data.get());
}
std::shared_ptr<Config> Mhwd::getInstalledConfig(const std::string& configName,
const std::string& configType)
{
......@@ -1101,7 +1077,7 @@ int Mhwd::launch(int argc, char *argv[])
{
if (arguments_.DETAIL)
{
printDeviceDetails("PCI");
printer_.printDeviceDetails(hw_pci);
}
else
{
......@@ -1112,7 +1088,7 @@ int Mhwd::launch(int argc, char *argv[])
{
if (arguments_.DETAIL)
{
printDeviceDetails("USB");
printer_.printDeviceDetails(hw_usb);
}
else
{
......
......@@ -79,8 +79,6 @@ private:
bool isUserRoot() const;
std::vector<std::string> checkEnvironment() const;
void printDeviceDetails(std::string type, FILE *f = stdout);
std::shared_ptr<Config> getInstalledConfig(const std::string& configName, const std::string& configType);
std::shared_ptr<Config> getDatabaseConfig(const std::string& configName, const std::string& configType);
std::shared_ptr<Config> getAvailableConfig(const std::string& configName, const std::string& configType);
......
......@@ -22,8 +22,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <hd.h>
#include <iomanip>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
......@@ -268,3 +271,17 @@ void Printer::printLine() const
{
std::cout << std::setfill('-') << std::setw(80) << "-" << std::setfill(' ') << std::endl;
}
void Printer::printDeviceDetails(hw_item hw, FILE *f)
{
std::unique_ptr<hd_data_t> hd_data{new hd_data_t()};
hd_t *hd = hd_list(hd_data.get(), hw, 1, nullptr);
for (hd_t* hdIter = hd; hdIter; hdIter = hdIter->next)
{
hd_dump_entry(hd_data.get(), hdIter, f);
}
hd_free_hd_list(hd);
hd_free_hd_data(hd_data.get());
}
......@@ -50,6 +50,7 @@ public:
void printInstalledConfigs(const std::string& deviceType,
const std::vector<std::shared_ptr<Config>>& installedConfigs) const;
void printConfigDetails(const Config& config) const;
void printDeviceDetails(hw_item hw, FILE *f = stdout);
private:
void printLine() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment