forked from tojocky/node-printer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode_printer.hpp
More file actions
123 lines (101 loc) · 2.82 KB
/
Copy pathnode_printer.hpp
File metadata and controls
123 lines (101 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef NODE_PRINTER_HPP
#define NODE_PRINTER_HPP
#include "macros.hh"
#include <node.h>
#include <v8.h>
#include <string>
/**
* Send data to printer
*
* @param data String/NativeBuffer, mandatory, raw data bytes
* @param printername String, mandatory, specifying printer name
* @param docname String, mandatory, specifying document name
* @param type String, mandatory, specifying data type. E.G.: RAW, TEXT, ...
*
* @returns true for success, false for failure.
*/
MY_NODE_MODULE_CALLBACK(PrintDirect);
/**
* Send file to printer
*
* @param filename String, mandatory, specifying filename to print
* @param docname String, mandatory, specifying document name
* @param printer String, mandatory, specifying printer name
*
* @returns jobId for success, or error message for failure.
*/
MY_NODE_MODULE_CALLBACK(PrintFile);
/** Retrieve all printers and jobs
* posix: minimum version: CUPS 1.1.21/OS X 10.4
*/
MY_NODE_MODULE_CALLBACK(getPrinters);
/**
* Return default printer name, if null then default printer is not set
*/
MY_NODE_MODULE_CALLBACK(getDefaultPrinterName);
/** Retrieve printer info and jobs
* @param printer name String
*/
MY_NODE_MODULE_CALLBACK(getPrinter);
/** Retrieve printer driver info
* @param printer name String
*/
MY_NODE_MODULE_CALLBACK(getPrinterDriverOptions);
/** Retrieve job info
* @param printer name String
* @param job id Number
*/
MY_NODE_MODULE_CALLBACK(getJob);
//TODO
/** Set job command.
* arguments:
* @param printer name String
* @param job id Number
* @param job command String
* Possible commands:
* "CANCEL"
* "PAUSE"
* "RESTART"
* "RESUME"
* "DELETE"
* "SENT-TO-PRINTER"
* "LAST-PAGE-EJECTED"
* "RETAIN"
* "RELEASE"
*/
MY_NODE_MODULE_CALLBACK(setJob);
/** Get supported print formats for printDirect. It depends on platform
*/
MY_NODE_MODULE_CALLBACK(getSupportedPrintFormats);
/** Get supported job commands for setJob method
*/
MY_NODE_MODULE_CALLBACK(getSupportedJobCommands);
//TODO:
// optional ability to get printer spool
// util class
/** Memory value class management to avoid memory leak
* TODO: move to std::unique_ptr on switching to C++11
*/
template<typename Type>
class MemValueBase
{
public:
MemValueBase(): _value(NULL) {}
/** Destructor. The allocated memory will be deallocated
*/
virtual ~MemValueBase() {}
Type * get() {return _value; }
Type * operator ->() { return &_value; }
operator bool() const { return (_value != NULL); }
protected:
Type *_value;
virtual void free() {};
};
/**
* try to extract String or buffer from v8 value
* @param iV8Value - source v8 value
* @param oData - destination data
* @return TRUE if value is String or Buffer, FALSE otherwise
*/
bool getStringOrBufferFromV8Value(v8::Local<v8::Value> iV8Value, std::string &oData);
#endif