Commit 1ba19e37 authored by Philip Müller's avatar Philip Müller

prepare v0.5.2

parents c5659747 4592f4fb
......@@ -2,3 +2,5 @@ Main developers:
Roland Singer <roland@manjaro.org>
Code refactoring:
Łukasz Matysiak <december0123@gmail.com>
Developers / Contributors:
Filipe Marques <eagle.software3@gmail.com>
/*
* Config.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <fstream>
......
/*
* Config.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_HPP_
......
This diff is collapsed.
/*
* Data.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATA_HPP_
......@@ -74,7 +91,7 @@ private:
void updateConfigData();
Vita::string from_Hex(uint16_t hexnum, int fill);
Vita::string from_CharArray(char* c);
std::string from_CharArray(char* c);
};
#endif /* DATA_HPP_ */
/*
* Device.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Device.hpp"
......
/*
* Device.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEVICE_HPP_
......@@ -13,7 +30,6 @@
#include <vector>
#include "Config.hpp"
#include "Enums.hpp"
struct Device
{
......
/*
* Enums.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ENUMS_HPP_
......
This diff is collapsed.
/*
* 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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 26 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MHWD_HPP_
......@@ -32,29 +49,32 @@ class Mhwd
{
public:
Mhwd();
~Mhwd();
~Mhwd() = default;
void setVersionMhwd(std::string versionOfSoftware, std::string yearCopyright);
int launch(int argc, char *argv[]);
private:
struct Arguments
{
bool SHOWPCI = false;
bool SHOWUSB = false;
bool SHOW_PCI = false;
bool SHOW_USB = false;
bool INSTALL = false;
bool REMOVE = false;
bool DETAIL = false;
bool FORCE = false;
bool LISTALL = false;
bool LISTINSTALLED = false;
bool LISTAVAILABLE = false;
bool LISTHARDWARE = false;
bool CUSTOMINSTALL = false;
bool LIST_ALL = false;
bool LIST_INSTALLED = false;
bool LIST_AVAILABLE = false;
bool LIST_HARDWARE = false;
bool CUSTOM_INSTALL = false;
bool AUTOCONFIGURE = false;
} arguments_;
std::shared_ptr<Config> config_;
Data data_;
Printer printer_;
std::vector<std::string> configs_;
std::string version_, year_;
bool performTransaction(std::shared_ptr<Config> config, MHWD::TRANSACTIONTYPE type);
bool isUserRoot() const;
std::string checkEnvironment();
......@@ -81,6 +101,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;
};
#endif /* MHWD_HPP_ */
/*
* Printer.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iomanip>
......@@ -32,38 +49,33 @@ void Printer::printWarning(std::string warningMsg) const
void Printer::printMessage(MHWD::MESSAGETYPE type, std::string msg) const
{
if (type == MHWD::MESSAGETYPE::CONSOLE_OUTPUT)
{
std::cout << CONSOLE_TEXT_OUTPUT_COLOR << msg << CONSOLE_COLOR_RESET;
}
else if (type == MHWD::MESSAGETYPE::INSTALLDEPENDENCY_START)
{
printStatus("Installing dependency " + msg + "...");
}
else if (type == MHWD::MESSAGETYPE::INSTALLDEPENDENCY_END)
{
printStatus("Successfully installed dependency " + msg);
}
else if (type == MHWD::MESSAGETYPE::INSTALL_START)
{
printStatus("Installing " + msg + "...");
}
else if (type == MHWD::MESSAGETYPE::INSTALL_END)
{
printStatus("Successfully installed " + msg);
}
else if (type == MHWD::MESSAGETYPE::REMOVE_START)
{
printStatus("Removing " + msg + "...");
}
else if (type == MHWD::MESSAGETYPE::REMOVE_END)
{
printStatus("Successfully removed " + msg);
}
else
{
printError("You shouldn't see this?! Unknown message type!");
}
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
......@@ -72,6 +84,7 @@ void Printer::printHelp() const
<< " --pci\t\t\t\t\tlist only pci devices and driver configs\n"
<< " --usb\t\t\t\t\tlist only usb devices and driver configs\n"
<< " -h/--help\t\t\t\tshow help\n"
<< " -v/--version\t\t\t\tshow version of mhwd\n"
<< " -f/--force\t\t\t\tforce reinstallation\n"
<< " -d/--detail\t\t\t\tshow detailed info for -l/-li/-lh\n"
<< " -l/--list\t\t\t\tlist available configs for devices\n"
......@@ -87,6 +100,15 @@ 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
{
std::cout << "Manjaro Hardware Detection version "<< versionMhwd <<"\n\n"
<< "Copyright (C) "<< yearCopy <<" Manjaro Linux Developers\n"
<< "This is free software licensed under GNU GPL v.3\n"
<< "FITNESS FOR A PARTICULAR PURPOSE.\n"
<< std::endl;
}
void Printer::listDevices(const std::vector<std::shared_ptr<Device>>& devices, std::string type) const
{
if (devices.empty())
......@@ -104,7 +126,7 @@ void Printer::listDevices(const std::vector<std::shared_ptr<Device>>& devices, s
<< std::setw(8) << "DEVICE"
<< std::setw(10) << "CONFIGS" << std::endl;
printLine();
for (auto&& device : devices)
for (const auto& device : devices)
{
std::cout << std::setw(30) << device->className_
<< std::setw(15) << device->sysfsBusID_
......@@ -126,7 +148,7 @@ void Printer::listConfigs(const std::vector<std::shared_ptr<Config>>& configs, s
<< std::setw(20) << "FREEDRIVER"
<< std::setw(15) << "TYPE" << std::endl;
printLine();
for (auto&& config : configs)
for (const auto& config : configs)
{
std::cout << std::setw(22) << config->name_
<< std::setw(22) << config->version_
......@@ -141,7 +163,7 @@ void Printer::printAvailableConfigsInDetail(const std::string& deviceType,
{
bool configFound = false;
for (auto&& device : devices)
for (const auto& device : devices)
{
if (device->availableConfigs_.empty() && device->installedConfigs_.empty())
{
......@@ -161,16 +183,16 @@ void Printer::printAvailableConfigsInDetail(const std::string& deviceType,
printLine();
if (!device->installedConfigs_.empty())
{
std::cout << " > INSTALLED:" << std::endl;
std::cout << " > INSTALLED:\n\n";
for (auto&& installedConfig : device->installedConfigs_)
{
printConfigDetails(*installedConfig);
}
std::cout << std::endl << std::endl;
std::cout << "\n\n";
}
if (!device->availableConfigs_.empty())
{
std::cout << " > AVAILABLE:" << std::endl;
std::cout << " > AVAILABLE:\n\n";
for (auto&& availableConfig : device->availableConfigs_)
{
printConfigDetails(*availableConfig);
......@@ -195,7 +217,7 @@ void Printer::printInstalledConfigs(const std::string& deviceType,
}
else
{
for (auto&& config : installedConfigs)
for (const auto& config : installedConfigs)
{
printConfigDetails(*config);
}
......@@ -207,25 +229,25 @@ void Printer::printConfigDetails(const Config& config) const
{
std::string classids;
std::string vendorids;
for (auto&& hwd : config.hwdIDs_)
for (const auto& hwd : config.hwdIDs_)
{
for (auto&& vendorID : hwd.vendorIDs)
for (const auto& vendorID : hwd.vendorIDs)
{
vendorids += vendorID + " ";
}
for (auto&& classID : hwd.classIDs)
for (const auto& classID : hwd.classIDs)
{
classids += classID + " ";
}
}
std::string dependencies;
for (auto&& dependency : config.dependencies_)
for (const auto& dependency : config.dependencies_)
{
dependencies += dependency + " ";
}
std::string conflicts;
for (auto&& conflict : config.conflicts_)
for (const auto& conflict : config.conflicts_)
{
conflicts += conflict + " ";
}
......@@ -239,7 +261,7 @@ void Printer::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 << std::endl;
<< "\n VENDORIDS:\t" << vendorids << "\n" << std::endl;
}
void Printer::printLine() const
......
/*
* Printer.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PRINTER_HPP_
......@@ -23,7 +40,9 @@ public:
void printWarning(std::string warningMsg) const;
void printMessage(MHWD::MESSAGETYPE type, std::string str) const;
void printHelp() const;
void listDevices(const std::vector<std::shared_ptr<Device>>& devices, std::string typeOfDevice) 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,
std::string header) const;
void printAvailableConfigsInDetail(const std::string& deviceType,
......@@ -34,9 +53,9 @@ public:
private:
void printLine() const;
const char* CONSOLE_COLOR_RESET {"\e[m"};
const char* CONSOLE_MESSAGE_COLOR {"\e[1m\e[31m"};
const char* CONSOLE_TEXT_OUTPUT_COLOR {"\e[0;32m"};
const char* CONSOLE_COLOR_RESET {"\033[m"};
const char* CONSOLE_MESSAGE_COLOR {"\033[1m\033[31m"};
const char* CONSOLE_TEXT_OUTPUT_COLOR {"\033[0;32m"};
};
#endif /* PRINTER_HPP_ */
/*
* 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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Transaction.hpp"
......
/*
* Transaction.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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Created on: 28 sie 2014
* Author: dec
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRANSACTION_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>
* Filipe Marques <eagle.software3@gmail.com>
*
* Copyright (C) 2007 Free Software Foundation, Inc.
*
......@@ -17,10 +21,22 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Mhwd.hpp"
#include <iostream>
int main(int argc, char *argv[])
{
Mhwd mhwd;
return mhwd.launch(argc, argv);
try
{
Mhwd mhwd;
mhwd.setVersionMhwd("0.5.2","2012 2013 2014 2015");
return mhwd.launch(argc, argv);
}
catch(...)
{
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