cupsffi 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cupsffi/printer.rb +30 -0
- data/lib/cupsffi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a5cd6973b7ece239ff8614b8c3384b899e7a4e8
|
4
|
+
data.tar.gz: 77f55e3774e3756b12c62296e41f46fb530e662a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f78e1817e9bd0f32e2b1180226491c82571e01513dcc7343170f98a4ed18e0efb1da4f5f520bab8cb27e095fd484bd5435ba5bf625047313c0247e2e7ff6118
|
7
|
+
data.tar.gz: 3104a28ae4f212e82e0000b5a46e4afc175d0fbe2057480cbcb9039d32aaacfd8537de0e0917b14d00e66da71d62dd4446f7a2d40f789320fdea2fe69eb7de72
|
data/lib/cupsffi/printer.rb
CHANGED
@@ -20,6 +20,8 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
+
require 'date'
|
24
|
+
|
23
25
|
class CupsPrinter
|
24
26
|
attr_reader :name, :connection
|
25
27
|
|
@@ -100,6 +102,7 @@ class CupsPrinter
|
|
100
102
|
hash[options[:name].dup] = options[:value].dup
|
101
103
|
end
|
102
104
|
end
|
105
|
+
hash
|
103
106
|
end
|
104
107
|
|
105
108
|
def state
|
@@ -183,6 +186,33 @@ class CupsPrinter
|
|
183
186
|
raise CupsFFI::cupsLastErrorString() if r == 0
|
184
187
|
end
|
185
188
|
|
189
|
+
def get_all_jobs(which = CupsFFI::CUPS_WHICHJOBS_ACTIVE)
|
190
|
+
pointer = FFI::MemoryPointer.new :pointer
|
191
|
+
job_count = CupsFFI::cupsGetJobs(pointer, @name, 0, which)
|
192
|
+
|
193
|
+
jobs = []
|
194
|
+
job_count.times do |i|
|
195
|
+
job = CupsFFI::CupsJobS.new(pointer.get_pointer(0) + (CupsFFI::CupsJobS.size * i))
|
196
|
+
|
197
|
+
jobs << {
|
198
|
+
:completed_time => job[:completed_time].nil? ? nil : DateTime.strptime(job[:completed_time].to_s, "%s"),
|
199
|
+
:creation_time => job[:creation_time].nil? ? nil : DateTime.strptime(job[:creation_time].to_s, "%s"),
|
200
|
+
:processing_time => job[:processing_time].nil? ? nil : DateTime.strptime(job[:processing_time].to_s, "%s"),
|
201
|
+
:dest => job[:dest].nil? ? nil : job[:dest].dup,
|
202
|
+
:format => job[:format].nil? ? nil : job[:format].dup,
|
203
|
+
:id => job[:id],
|
204
|
+
:priority => job[:priority],
|
205
|
+
:size => job[:size],
|
206
|
+
:title => job[:title].nil? ? nil : job[:title].dup,
|
207
|
+
:user => job[:user].nil? ? nil : job[:user].dup,
|
208
|
+
:state => job[:state].nil? ? nil : job[:state]
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
CupsFFI::cupsFreeJobs(job_count, pointer.get_pointer(0))
|
213
|
+
jobs
|
214
|
+
end
|
215
|
+
|
186
216
|
|
187
217
|
private
|
188
218
|
def validate_options(options)
|
data/lib/cupsffi/version.rb
CHANGED