Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Applications
mhwd
Commits
d34c2273
Commit
d34c2273
authored
Apr 28, 2015
by
Philip Müller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development'
parents
3fcc73de
9a822c85
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
402 additions
and
402 deletions
+402
-402
src/CMakeLists.txt
src/CMakeLists.txt
+8
-8
src/Config.cpp
src/Config.cpp
+1
-1
src/ConsoleWriter.cpp
src/ConsoleWriter.cpp
+45
-45
src/ConsoleWriter.hpp
src/ConsoleWriter.hpp
+1
-1
src/Data.cpp
src/Data.cpp
+18
-18
src/Mhwd.cpp
src/Mhwd.cpp
+314
-314
src/Mhwd.hpp
src/Mhwd.hpp
+7
-7
src/Transaction.hpp
src/Transaction.hpp
+2
-2
src/main.cpp
src/main.cpp
+6
-6
No files found.
src/CMakeLists.txt
View file @
d34c2273
...
...
@@ -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
)
...
...
src/Config.cpp
View file @
d34c2273
/*
* 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>
...
...
src/
P
ri
n
ter.cpp
→
src/
ConsoleW
riter.cpp
View file @
d34c2273
/*
* 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 "
P
ri
n
ter.hpp"
#include "
ConsoleW
riter.hpp"
#include <hd.h>
...
...
@@ -32,56 +32,56 @@
#include <string>
#include <vector>
void
P
ri
n
ter
::
printStatus
(
std
::
string
statusMsg
)
const
void
ConsoleW
riter
::
printStatus
(
std
::
string
statusMsg
)
const
{
std
::
cout
<<
CONSOLE_RED_MESSAGE_COLOR
<<
"> "
<<
CONSOLE_COLOR_RESET
<<
statusMsg
<<
std
::
endl
;
}
void
P
ri
n
ter
::
printError
(
std
::
string
errorMsg
)
const
void
ConsoleW
riter
::
printError
(
std
::
string
errorMsg
)
const
{
std
::
cout
<<
CONSOLE_RED_MESSAGE_COLOR
<<
"Error: "
<<
CONSOLE_COLOR_RESET
<<
errorMsg
<<
std
::
endl
;
}
void
P
ri
n
ter
::
printWarning
(
std
::
string
warningMsg
)
const
void
ConsoleW
riter
::
printWarning
(
std
::
string
warningMsg
)
const
{
std
::
cout
<<
CONSOLE_RED_MESSAGE_COLOR
<<
"Warning: "
<<
CONSOLE_COLOR_RESET
<<
warningMsg
<<
std
::
endl
;
}
void
P
ri
n
ter
::
printMessage
(
MHWD
::
MESSAGETYPE
type
,
std
::
string
msg
)
const
void
ConsoleW
riter
::
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
P
ri
n
ter
::
printHelp
()
const
void
ConsoleW
riter
::
printHelp
()
const
{
std
::
cout
<<
"Usage: mhwd [OPTIONS] <config(s)>
\n\n
"
<<
" --pci
\t\t\t\t\t
list only pci devices and driver configs
\n
"
...
...
@@ -103,16 +103,16 @@ void Printer::printHelp() const
<<
" --pmroot <path>
\t\t\t
set package manager root
\n
"
<<
std
::
endl
;
}
void
P
ri
n
ter
::
printVersion
(
std
::
string
versionMhwd
,
std
::
string
yearCopy
)
const
void
ConsoleW
riter
::
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
P
ri
n
ter
::
listDevices
(
const
std
::
vector
<
std
::
shared_ptr
<
Device
>>&
devices
,
std
::
string
type
)
const
void
ConsoleW
riter
::
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
P
ri
n
ter
::
listConfigs
(
const
std
::
vector
<
std
::
shared_ptr
<
Config
>>&
configs
,
std
::
string
header
)
const
void
ConsoleW
riter
::
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
P
ri
n
ter
::
printAvailableConfigsInDetail
(
const
std
::
string
&
deviceType
,
void
ConsoleW
riter
::
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
P
ri
n
ter
::
printInstalledConfigs
(
const
std
::
string
&
deviceType
,
void
ConsoleW
riter
::
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
P
ri
n
ter
::
printConfigDetails
(
const
Config
&
config
)
const
void
ConsoleW
riter
::
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
P
ri
n
ter
::
printLine
()
const
void
ConsoleW
riter
::
printLine
()
const
{
std
::
cout
<<
std
::
s
etfill
(
'-'
)
<<
std
::
setw
(
80
)
<<
"-"
<<
std
::
setfill
(
'
'
)
<<
std
::
endl
;
std
::
cout
<<
std
::
s
tring
(
80
,
'-
'
)
<<
std
::
endl
;
}
void
P
ri
n
ter
::
printDeviceDetails
(
hw_item
hw
,
FILE
*
f
)
const
void
ConsoleW
riter
::
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
);
...
...
src/
P
ri
n
ter.hpp
→
src/
ConsoleW
riter.hpp
View file @
d34c2273
...
...
@@ -34,7 +34,7 @@
#include "Device.hpp"
#include "Enums.hpp"
class
P
ri
n
ter
class
ConsoleW
riter
{
public:
void
printStatus
(
std
::
string
statusMsg
)
const
;
...
...
src/Data.cpp
View file @
d34c2273
/*
* 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
++
)
...
...
src/Mhwd.cpp
View file @
d34c2273
This diff is collapsed.
Click to expand it.
src/Mhwd.hpp
View file @
d34c2273
/*
* 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_
;
P
ri
n
ter
p
ri
n
ter_
;
ConsoleW
riter
consoleW
riter_
;
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_ */
src/Transaction.hpp
View file @
d34c2273
/*
* 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_
;
...
...
src/main.cpp
View file @
d34c2273
/*
* 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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment