Skip to content

Commit

Permalink
Add state warning verdict function
Browse files Browse the repository at this point in the history
  • Loading branch information
attah committed Jul 13, 2024
1 parent 2103e19 commit c5c66ca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/ippprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,22 @@ bool IppPrinter::Firmware::operator==(const IppPrinter::Firmware& other) const
other.version == version;
}

bool IppPrinter::isWarningState()
{
if(state() > 4)
{
return true;
}
for(const std::string& reason : stateReasons())
{
if(reason != "none" && !(string_ends_with(reason, "-report")))
{
return true;
}
}
return false;
}

Error IppPrinter::identify()
{
if(!identifySupported())
Expand Down
2 changes: 2 additions & 0 deletions lib/ippprinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class IppPrinter
List<std::string> possibleInputFormats();
bool supportsPrinterRaster();

bool isWarningState();

bool identifySupported();
Error identify();
Error setAttributes(List<std::pair<std::string, std::string>> attrStrs);
Expand Down
1 change: 1 addition & 0 deletions tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,7 @@ TEST(attribute_getters)
ASSERT(ip.state() == 3);
ASSERT(ip.stateMessage() == "State.");
ASSERT(ip.stateReasons() == List<std::string> {"none"});
ASSERT_FALSE(ip.isWarningState());
ASSERT(ip.ippVersionsSupported() == (List<std::string> {"1.1", "2.0"}));
ASSERT(ip.ippFeaturesSupported() == List<std::string> {"ipp-everywhere"});
ASSERT(ip.pagesPerMinute() == 42);
Expand Down

0 comments on commit c5c66ca

Please sign in to comment.