-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "ippprinter.h" | ||
#include "curlrequester.h" | ||
|
||
IppPrinter::IppPrinter(std::string addr) : _addr(addr) | ||
{ | ||
_error = refresh(); | ||
} | ||
|
||
Error IppPrinter::refresh() | ||
{ | ||
Error error; | ||
IppAttrs getPrinterAttrsJobAttrs = IppMsg::baseOpAttrs(_addr); | ||
IppMsg getPrinterAttrsMsg(IppMsg::GetPrinterAttrs, getPrinterAttrsJobAttrs); | ||
|
||
CurlIppPoster getPrinterAttrsReq(_addr, getPrinterAttrsMsg.encode(), _ignoreSslErrors, _verbose); | ||
Bytestream getPrinterAttrsResult; | ||
CURLcode res0 = getPrinterAttrsReq.await(&getPrinterAttrsResult); | ||
if(res0 == CURLE_OK) | ||
{ | ||
try | ||
{ | ||
IppMsg getPrinterAttrsResp(getPrinterAttrsResult); | ||
_printerAttrs = getPrinterAttrsResp.getPrinterAttrs(); | ||
} | ||
catch(const std::exception& e) | ||
{ | ||
error = e.what(); | ||
} | ||
} | ||
else | ||
{ | ||
error = curl_easy_strerror(res0); | ||
} | ||
return error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#ifndef IPPPRINTER_H | ||
#define IPPPRINTER_H | ||
|
||
#include <string> | ||
#include "error.h" | ||
#include "ippattr.h" | ||
#include "ippmsg.h" | ||
#include "ippprintjob.h" | ||
|
||
class IppPrinter | ||
{ | ||
public: | ||
IppPrinter() = delete; | ||
IppPrinter(std::string addr); | ||
Error refresh(); | ||
|
||
IppAttrs attributes() | ||
{ | ||
return _printerAttrs; | ||
} | ||
|
||
Error error() | ||
{ | ||
return _error; | ||
} | ||
|
||
IppPrintJob createJob() | ||
{ | ||
return IppPrintJob(_printerAttrs); | ||
} | ||
|
||
private: | ||
std::string _addr; | ||
bool _verbose = false; | ||
bool _ignoreSslErrors = true; | ||
|
||
Error _error; | ||
IppAttrs _printerAttrs; | ||
|
||
}; | ||
|
||
#endif //IPPPRINTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters