Commit 3d5cc3ea authored by Filipe Marques's avatar Filipe Marques
Browse files

Changing source and Readme files

parent 372a6c97
......@@ -41,6 +41,10 @@ void Mhwd::setVersionMhwd(std::string versionOfSoftware, std::string yearCopyrig
}
```
#### Indentation of Code
Don't use tabs, instead use spaces and count 4 characters.
#### Software need for coding or testing
* C++ tool chain: [g++](https://gcc.gnu.org/) or [clang](http://clang.llvm.org/), [cmake](http://www.cmake.org/), [make](http://www.gnu.org/software/make/)
......
......@@ -35,19 +35,19 @@
void ConsoleWriter::printStatus(std::string statusMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "> "
<< CONSOLE_COLOR_RESET << statusMsg << std::endl;
<< CONSOLE_COLOR_RESET << statusMsg << "\n";
}
void ConsoleWriter::printError(std::string errorMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "Error: "
<< CONSOLE_COLOR_RESET << errorMsg << std::endl;
<< CONSOLE_COLOR_RESET << errorMsg << "\n";
}
void ConsoleWriter::printWarning(std::string warningMsg) const
{
std::cout << CONSOLE_RED_MESSAGE_COLOR << "Warning: "
<< CONSOLE_COLOR_RESET << warningMsg << std::endl;
<< CONSOLE_COLOR_RESET << warningMsg << "\n";
}
void ConsoleWriter::printMessage(MHWD::MESSAGETYPE type, std::string msg) const
......@@ -100,16 +100,16 @@ void ConsoleWriter::printHelp() const
<< " -a/--auto <usb/pci> <free/nonfree> <classid>\tauto install configs for classid\n"
<< " --pmcachedir <path>\t\t\tset package manager cache path\n"
<< " --pmconfig <path>\t\t\tset package manager config\n"
<< " --pmroot <path>\t\t\tset package manager root\n" << std::endl;
<< " --pmroot <path>\t\t\tset package manager root\n" << "\n";
}
void ConsoleWriter::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"
<< "Copyright (C) "<< yearCopy <<" Manjaro Linux Developers\n"
<< "This is free software licensed under GNU GPL v3.0\n"
<< "FITNESS FOR A PARTICULAR PURPOSE.\n"
<< std::endl;
<< "\n";
}
void ConsoleWriter::listDevices(const std::vector<std::shared_ptr<Device>>& devices, std::string type) const
......@@ -127,7 +127,7 @@ void ConsoleWriter::listDevices(const std::vector<std::shared_ptr<Device>>& devi
<< std::setw(8) << "CLASS"
<< std::setw(8) << "VENDOR"
<< std::setw(8) << "DEVICE"
<< std::setw(10) << "CONFIGS" << std::endl;
<< std::setw(10) << "CONFIGS" << "\n";
printLine();
for (const auto& device : devices)
{
......@@ -136,9 +136,9 @@ void ConsoleWriter::listDevices(const std::vector<std::shared_ptr<Device>>& devi
<< std::setw(8) << device->classID_
<< std::setw(8) << device->vendorID_
<< std::setw(8) << device->deviceID_
<< std::setw(10) << device->availableConfigs_.size() << std::endl;
<< std::setw(10) << device->availableConfigs_.size() << "\n";
}
std::cout << std::endl << std::endl;
std::cout << "\n\n";
}
}
......@@ -149,16 +149,16 @@ void ConsoleWriter::listConfigs(const std::vector<std::shared_ptr<Config>>& conf
std::cout << std::setw(22) << "NAME"
<< std::setw(22) << "VERSION"
<< std::setw(20) << "FREEDRIVER"
<< std::setw(15) << "TYPE" << std::endl;
<< std::setw(15) << "TYPE" << "\n";
printLine();
for (const auto& config : configs)
{
std::cout << std::setw(22) << config->name_
<< std::setw(22) << config->version_
<< std::setw(20) << std::boolalpha << config->freedriver_
<< std::setw(15) << config->type_ << std::endl;
<< std::setw(15) << config->type_ << "\n";
}
std::cout << std::endl << std::endl;
std::cout << "\n\n";
}
void ConsoleWriter::printAvailableConfigsInDetail(const std::string& deviceType,
......@@ -182,7 +182,7 @@ void ConsoleWriter::printAvailableConfigsInDetail(const std::string& deviceType,
+ device->vendorID_ + ":" + device->deviceID_ + ")");
std::cout << " " << device->className_
<< " " << device->vendorName_
<< " " << device->deviceName_ << std::endl;
<< " " << device->deviceName_ << "\n";
printLine();
if (!device->installedConfigs_.empty())
{
......@@ -200,7 +200,7 @@ void ConsoleWriter::printAvailableConfigsInDetail(const std::string& deviceType,
{
printConfigDetails(*availableConfig);
}
std::cout << std::endl;
std::cout << "\n";
}
}
}
......@@ -224,7 +224,7 @@ void ConsoleWriter::printInstalledConfigs(const std::string& deviceType,
{
printConfigDetails(*config);
}
std::cout << std::endl;
std::cout << "\n";
}
}
......@@ -264,12 +264,12 @@ void ConsoleWriter::printConfigDetails(const Config& config) const
<< "\n DEPENDS:\t" << (dependencies.empty() ? "-" : dependencies)
<< "\n CONFLICTS:\t" << (conflicts.empty() ? "-" : conflicts)
<< "\n CLASSIDS:\t" << classids
<< "\n VENDORIDS:\t" << vendorids << "\n" << std::endl;
<< "\n VENDORIDS:\t" << vendorids << "\n\n";
}
void ConsoleWriter::printLine() const
{
std::cout << std::string(80, '-') << std::endl;
std::cout << std::string(80, '-') << "\n";
}
void ConsoleWriter::printDeviceDetails(hw_item hw, FILE *f) const
......
......@@ -42,7 +42,7 @@ public:
void printWarning(std::string warningMsg) const;
void printMessage(MHWD::MESSAGETYPE type, std::string str) const;
void printHelp() const;
void printVersion(std::string versionMhwd, std::string yearCopy) const;
void printVersion(std::string& versionMhwd, std::string& yearCopy) const;
void listDevices(const std::vector<std::shared_ptr<Device>>& devices,
std::string typeOfDevice) const;
void listConfigs(const std::vector<std::shared_ptr<Config>>& configs,
......
......@@ -552,8 +552,7 @@ MHWD::STATUS Mhwd::installConfig(std::shared_ptr<Config> config)
MHWD::STATUS Mhwd::uninstallConfig(Config *config)
{
std::shared_ptr<Config> installedConfig{getInstalledConfig(config->name_, config->type_)};
std::vector<std::shared_ptr<Config>> localRequirements{data_.getAllLocalRequirements(installedConfig)};
// Check if installed
if (nullptr == installedConfig)
{
......@@ -565,19 +564,15 @@ MHWD::STATUS Mhwd::uninstallConfig(Config *config)
}
else
{
// Should we check for local requirements here?
if(!localRequirements.empty())
// Run script
if (!runScript(installedConfig, MHWD::TRANSACTIONTYPE::REMOVE))
{
// Run script
if (!runScript(installedConfig, MHWD::TRANSACTIONTYPE::REMOVE))
{
return MHWD::STATUS::ERROR_SCRIPT_FAILED;
}
return MHWD::STATUS::ERROR_SCRIPT_FAILED;
}
if (!removeDirectory(installedConfig->basePath_))
{
return MHWD::STATUS::ERROR_SET_DATABASE;
}
if (!removeDirectory(installedConfig->basePath_))
{
return MHWD::STATUS::ERROR_SET_DATABASE;
}
// Installed config vectors have to be updated manual with updateInstalledConfigData(Data*)
......@@ -619,7 +614,7 @@ bool Mhwd::runScript(std::shared_ptr<Config> config, MHWD::TRANSACTIONTYPE opera
for (auto&& foundDevice = foundDevices.begin();
foundDevice != foundDevices.end(); ++foundDevice)
{
static bool found = false;
bool found = false;
// Check if already in list
for (auto&& dev = devices.begin(); dev != devices.end(); ++dev)
......
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