Commit d34c2273 authored by Philip Müller's avatar Philip Müller

Merge branch 'development'

parents 3fcc73de 9a822c85
......@@ -5,22 +5,22 @@ include_directories(. ${mhwd_SOURCE_DIR}/libmhwd)
###
set( HEADERS
Config.hpp
Data.hpp
Device.hpp
Enums.hpp
Mhwd.hpp
Printer.hpp
Transaction.hpp
Config.hpp
ConsoleWriter.hpp
Data.hpp
Device.hpp
Enums.hpp
Mhwd.hpp
Transaction.hpp
)
set( SOURCES
Config.cpp
ConsoleWriter.cpp
Data.cpp
Device.cpp
main.cpp
Mhwd.cpp
Printer.cpp
Transaction.cpp
)
......
/*
* This file is part of the mhwd - Manjaro Hardware Detection project
*
*
* mhwd - Manjaro Hardware Detection
* Roland Singer <roland@manjaro.org>
* Łukasz Matysiak <december0123@gmail.com>
......
/*
* This file is part of the mhwd - Manjaro Hardware Detection project
*
*
* mhwd - Manjaro Hardware Detection
* Roland Singer <roland@manjaro.org>
* Łukasz Matysiak <december0123@gmail.com>
......@@ -22,7 +22,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Printer.hpp"
#include "ConsoleWriter.hpp"
#include <hd.h>
......@@ -32,56 +32,56 @@
#include <string>
#include <vector>
void Printer::printStatus(std::string statusMsg) const
void ConsoleWriter::printStatus(std::string statusMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "> "
<< CONSOLE_COLOR_RESET << statusMsg << std::endl;
}
void Printer::printError(std::string errorMsg) const
void ConsoleWriter::printError(std::string errorMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "Error: "
<< CONSOLE_COLOR_RESET << errorMsg << std::endl;
}
void Printer::printWarning(std::string warningMsg) const
void ConsoleWriter::printWarning(std::string warningMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "Warning: "
<< CONSOLE_COLOR_RESET << warningMsg << std::endl;
}
void Printer::printMessage(MHWD::MESSAGETYPE type, std::string msg) const
void ConsoleWriter::printMessage(MHWD::MESSAGETYPE type, std::string msg) const
{
switch(type)
{
case MHWD::MESSAGETYPE::CONSOLE_OUTPUT:
std::cout << CONSOLE_TEXT_OUTPUT_COLOR << msg << CONSOLE_COLOR_RESET;
break;
case MHWD::MESSAGETYPE::INSTALLDEPENDENCY_START:
printStatus("Installing dependency " + msg + "...");
break;
case MHWD::MESSAGETYPE::INSTALLDEPENDENCY_END:
printStatus("Successfully installed dependency " + msg);
break;
case MHWD::MESSAGETYPE::INSTALL_START:
printStatus("Installing " + msg + "...");
break;
case MHWD::MESSAGETYPE::INSTALL_END:
printStatus("Successfully installed " + msg);
break;
case MHWD::MESSAGETYPE::REMOVE_START:
printStatus("Removing " + msg + "...");
break;
case MHWD::MESSAGETYPE::REMOVE_END:
printStatus("Successfully removed " + msg);
break;
default:
printError("You shouldn't see this?! Unknown message type!");
break;
}
switch(type)
{
case MHWD::MESSAGETYPE::CONSOLE_OUTPUT:
std::cout << CONSOLE_TEXT_OUTPUT_COLOR << msg << CONSOLE_COLOR_RESET;
break;
case MHWD::MESSAGETYPE::INSTALLDEPENDENCY_START:
printStatus("Installing dependency " + msg + "...");
break;
case MHWD::MESSAGETYPE::INSTALLDEPENDENCY_END:
printStatus("Successfully installed dependency " + msg);
break;
case MHWD::MESSAGETYPE::INSTALL_START:
printStatus("Installing " + msg + "...");
break;
case MHWD::MESSAGETYPE::INSTALL_END:
printStatus("Successfully installed " + msg);
break;
case MHWD::MESSAGETYPE::REMOVE_START:
printStatus("Removing " + msg + "...");
break;
case MHWD::MESSAGETYPE::REMOVE_END:
printStatus("Successfully removed " + msg);
break;
default:
printError("You shouldn't see this?! Unknown message type!");
break;
}
}
void Printer::printHelp() const
void ConsoleWriter::printHelp() const
{
std::cout << "Usage: mhwd [OPTIONS] <config(s)>\n\n"
<< " --pci\t\t\t\t\tlist only pci devices and driver configs\n"
......@@ -103,16 +103,16 @@ void Printer::printHelp() const
<< " --pmroot <path>\t\t\tset package manager root\n" << std::endl;
}
void Printer::printVersion(std::string versionMhwd, std::string yearCopy) const
void ConsoleWriter::printVersion(std::string versionMhwd, std::string yearCopy) const
{
std::cout << "Manjaro Hardware Detection v"<< versionMhwd <<"\n\n"
std::cout << "Manjaro Hardware Detection v"<< versionMhwd <<"\n\n"
<< "Copyright (C) "<< yearCopy <<" Manjaro Linux Developers\n"
<< "This is free software licensed under GNU GPL v3.0\n"
<< "FITNESS FOR A PARTICULAR PURPOSE.\n"
<< "FITNESS FOR A PARTICULAR PURPOSE.\n"
<< std::endl;
}
void Printer::listDevices(const std::vector<std::shared_ptr<Device>>& devices, std::string type) const
void ConsoleWriter::listDevices(const std::vector<std::shared_ptr<Device>>& devices, std::string type) const
{
if (devices.empty())
{
......@@ -142,7 +142,7 @@ void Printer::listDevices(const std::vector<std::shared_ptr<Device>>& devices, s
}
}
void Printer::listConfigs(const std::vector<std::shared_ptr<Config>>& configs, std::string header) const
void ConsoleWriter::listConfigs(const std::vector<std::shared_ptr<Config>>& configs, std::string header) const
{
printStatus(header);
printLine();
......@@ -161,7 +161,7 @@ void Printer::listConfigs(const std::vector<std::shared_ptr<Config>>& configs, s
std::cout << std::endl << std::endl;
}
void Printer::printAvailableConfigsInDetail(const std::string& deviceType,
void ConsoleWriter::printAvailableConfigsInDetail(const std::string& deviceType,
const std::vector<std::shared_ptr<Device>>& devices) const
{
bool configFound = false;
......@@ -211,7 +211,7 @@ void Printer::printAvailableConfigsInDetail(const std::string& deviceType,
}
}
void Printer::printInstalledConfigs(const std::string& deviceType,
void ConsoleWriter::printInstalledConfigs(const std::string& deviceType,
const std::vector<std::shared_ptr<Config>>& installedConfigs) const
{
if (installedConfigs.empty())
......@@ -228,7 +228,7 @@ void Printer::printInstalledConfigs(const std::string& deviceType,
}
}
void Printer::printConfigDetails(const Config& config) const
void ConsoleWriter::printConfigDetails(const Config& config) const
{
std::string classids;
std::string vendorids;
......@@ -267,12 +267,12 @@ void Printer::printConfigDetails(const Config& config) const
<< "\n VENDORIDS:\t" << vendorids << "\n" << std::endl;
}
void Printer::printLine() const
void ConsoleWriter::printLine() const
{
std::cout << std::setfill('-') << std::setw(80) << "-" << std::setfill(' ') << std::endl;
std::cout << std::string(80, '-') << std::endl;
}
void Printer::printDeviceDetails(hw_item hw, FILE *f) const
void ConsoleWriter::printDeviceDetails(hw_item hw, FILE *f) const
{
std::unique_ptr<hd_data_t> hd_data{new hd_data_t()};
hd_t *hd = hd_list(hd_data.get(), hw, 1, nullptr);
......
......@@ -34,7 +34,7 @@
#include "Device.hpp"
#include "Enums.hpp"
class Printer
class ConsoleWriter
{
public:
void printStatus(std::string statusMsg) const;
......
/*
* This file is part of the mhwd - Manjaro Hardware Detection project
*
*
* mhwd - Manjaro Hardware Detection
* Roland Singer <roland@manjaro.org>
* Łukasz Matysiak <december0123@gmail.com>
......@@ -131,8 +131,8 @@ void Data::getAllDevicesOfConfig(const std::vector<std::shared_ptr<Device>>& dev
{
// Check class ids
bool found = std::find_if(hwdID->classIDs.begin(), hwdID->classIDs.end(), [i_device](const std::string& classID){
return (("*" == classID) || (classID == (*i_device)->classID_));
}) != hwdID->classIDs.end();
return (("*" == classID) || (classID == (*i_device)->classID_));
}) != hwdID->classIDs.end();
if (!found)
{
......@@ -142,8 +142,8 @@ void Data::getAllDevicesOfConfig(const std::vector<std::shared_ptr<Device>>& dev
{
// Check blacklisted class ids
found = std::find_if(hwdID->blacklistedClassIDs.begin(), hwdID->blacklistedClassIDs.end(), [i_device](const std::string& blacklistedClassID){
return (blacklistedClassID == (*i_device)->classID_);
}) != hwdID->blacklistedClassIDs.end();
return (blacklistedClassID == (*i_device)->classID_);
}) != hwdID->blacklistedClassIDs.end();
if (found)
{
......@@ -152,9 +152,9 @@ void Data::getAllDevicesOfConfig(const std::vector<std::shared_ptr<Device>>& dev
else
{
// Check vendor ids
found = std::find_if(hwdID->vendorIDs.begin(), hwdID->vendorIDs.end(), [i_device](const std::string& vendorID){
return (("*" == vendorID) || (vendorID == (*i_device)->vendorID_));
}) != hwdID->vendorIDs.end();
found = std::find_if(hwdID->vendorIDs.begin(), hwdID->vendorIDs.end(), [i_device](const std::string& vendorID){
return (("*" == vendorID) || (vendorID == (*i_device)->vendorID_));
}) != hwdID->vendorIDs.end();
if (!found)
{
......@@ -164,8 +164,8 @@ void Data::getAllDevicesOfConfig(const std::vector<std::shared_ptr<Device>>& dev
{
// Check blacklisted vendor ids
found = std::find_if(hwdID->blacklistedVendorIDs.begin(), hwdID->blacklistedVendorIDs.end(), [i_device](const std::string& blacklistedVendorID){
return (blacklistedVendorID == (*i_device)->vendorID_);
}) != hwdID->blacklistedVendorIDs.end();
return (blacklistedVendorID == (*i_device)->vendorID_);
}) != hwdID->blacklistedVendorIDs.end();
if (found)
{
......@@ -174,9 +174,9 @@ void Data::getAllDevicesOfConfig(const std::vector<std::shared_ptr<Device>>& dev
else
{
// Check device ids
found = std::find_if(hwdID->deviceIDs.begin(), hwdID->deviceIDs.end(), [i_device](const std::string& deviceID){
return (("*" == deviceID) || (deviceID == (*i_device)->deviceID_));
}) != hwdID->deviceIDs.end();
found = std::find_if(hwdID->deviceIDs.begin(), hwdID->deviceIDs.end(), [i_device](const std::string& deviceID){
return (("*" == deviceID) || (deviceID == (*i_device)->deviceID_));
}) != hwdID->deviceIDs.end();
if (!found)
{
......@@ -186,8 +186,8 @@ void Data::getAllDevicesOfConfig(const std::vector<std::shared_ptr<Device>>& dev
{
// Check blacklisted device ids
found = std::find_if(hwdID->blacklistedDeviceIDs.begin(), hwdID->blacklistedDeviceIDs.end(), [i_device](const std::string& blacklistedDeviceID){
return (blacklistedDeviceID == (*i_device)->deviceID_);
}) != hwdID->blacklistedDeviceIDs.end();
return (blacklistedDeviceID == (*i_device)->deviceID_);
}) != hwdID->blacklistedDeviceIDs.end();
if (found)
{
continue;
......@@ -265,7 +265,7 @@ void Data::getAllDependenciesToInstall(std::shared_ptr<Config> config,
{
// Add to vector and check for further subdepends...
std::shared_ptr<Config> dependconfig {
getDatabaseConfig((*configDependency), config->type_)};
getDatabaseConfig((*configDependency), config->type_)};
if (nullptr == dependconfig)
{
continue;
......@@ -596,7 +596,7 @@ void Data::setMatchingConfigs(const std::vector<std::shared_ptr<Device>>& device
}
void Data::setMatchingConfig(std::shared_ptr<Config> config,
const std::vector<std::shared_ptr<Device>>& devices, bool setAsInstalled)
const std::vector<std::shared_ptr<Device>>& devices, bool setAsInstalled)
{
std::vector<std::shared_ptr<Device>> foundDevices;
......@@ -618,7 +618,7 @@ void Data::setMatchingConfig(std::shared_ptr<Config> config,
}
void Data::addConfigSorted(std::vector<std::shared_ptr<Config>>& configs,
std::shared_ptr<Config> config)
std::shared_ptr<Config> config)
{
for (auto&& iterator = configs.begin();
iterator != configs.end(); iterator++)
......
This diff is collapsed.
/*
* This file is part of the mhwd - Manjaro Hardware Detection project
*
*
* mhwd - Manjaro Hardware Detection
* Roland Singer <roland@manjaro.org>
* Łukasz Matysiak <december0123@gmail.com>
......@@ -38,10 +38,10 @@
#include "Config.hpp"
#include "const.h"
#include "ConsoleWriter.hpp"
#include "Data.hpp"
#include "Device.hpp"
#include "Enums.hpp"
#include "Printer.hpp"
#include "vita/string.hpp"
#include "Transaction.hpp"
......@@ -71,10 +71,10 @@ private:
} arguments_;
std::shared_ptr<Config> config_;
Data data_;
Printer printer_;
ConsoleWriter consoleWriter_;
std::vector<std::string> configs_;
std::string version_, year_;
bool performTransaction(std::shared_ptr<Config> config, MHWD::TRANSACTIONTYPE type);
bool isUserRoot() const;
std::vector<std::string> checkEnvironment() const;
......@@ -99,9 +99,9 @@ private:
MHWD::STATUS installConfig(std::shared_ptr<Config> config);
MHWD::STATUS uninstallConfig(Config *config);
bool runScript(std::shared_ptr<Config> config, MHWD::TRANSACTIONTYPE operationType);
void tryToParseCmdLineOptions(int argc, char* argv[], bool& autoConfigureNonFreeDriver,
std::string& operationType, std::string& autoConfigureClassID);
bool optionsDontInterfereWithEachOther() const;
void tryToParseCmdLineOptions(int argc, char* argv[], bool& autoConfigureNonFreeDriver,
std::string& operationType, std::string& autoConfigureClassID);
bool optionsDontInterfereWithEachOther() const;
};
#endif /* MHWD_HPP_ */
/*
* This file is part of the mhwd - Manjaro Hardware Detection project
*
*
* mhwd - Manjaro Hardware Detection
* Roland Singer <roland@manjaro.org>
* Łukasz Matysiak <december0123@gmail.com>
......@@ -36,7 +36,7 @@ class Transaction
public:
Transaction() = delete;
Transaction(Data data, std::shared_ptr<Config> config, MHWD::TRANSACTIONTYPE type,
bool allowReinstallation);
bool allowReinstallation);
bool isAllowedToReinstall() const;
std::shared_ptr<Config> config_;
......
/*
* This file is part of the mhwd - Manjaro Hardware Detection project
*
*
* mhwd - Manjaro Hardware Detection
* Roland Singer <roland@manjaro.org>
* Łukasz Matysiak <december0123@gmail.com>
......@@ -30,13 +30,13 @@ int main(int argc, char *argv[])
{
try
{
Mhwd mhwd;
mhwd.setVersionMhwd("0.5.4","2012-2015");
return mhwd.launch(argc, argv);
Mhwd mhwd;
mhwd.setVersionMhwd("0.5.5","2012-2015");
return mhwd.launch(argc, argv);
}
catch(...)
{
std::cerr << "Unknown errors occured...";
return -1;
std::cerr << "Unknown errors occured...";
return -1;
}
}
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