ffi-cups2 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/ffi-cups/connection.rb +4 -4
- data/lib/ffi-cups/job.rb +3 -3
- data/lib/ffi-cups/printer.rb +7 -7
- data/lib/ffi-cups/version.rb +1 -1
- data/lib/ffi-cups.rb +12 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eba1754e517994c97f2e5ba9267ec825f66e25d288034fa14c0f95b34a8e595e
|
|
4
|
+
data.tar.gz: 2e60bc299d09ce8e1140ed6a742668d299f9709c10bd3c7d12f8b0af873feede
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 479520947edf9e94cef4550f7ad3de1706c49eddb0e22a6fce94d4ea1c9562183863cef41e955e88cdceee2d13a3819fdb6f5a669d2eca2c79488f2cbbf02a5c
|
|
7
|
+
data.tar.gz: ffac852d7a53d8083b7b45869d260353b4a4697fddb2470068ccef370d51cc4b0811bdc6cc658c6a1627454069835539e19555b75df8791ae7824f5f5cd17525
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/ffi-cups/connection.rb
CHANGED
|
@@ -8,13 +8,13 @@ module Cups
|
|
|
8
8
|
@hostname = hostname
|
|
9
9
|
@port = port.nil? ? 631 : port
|
|
10
10
|
end
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
# Wrapper around {::Cups::Http#httpConnectEncrypt}
|
|
13
13
|
# @deprecated Use {#httpConnect2} instead
|
|
14
|
-
# @return [Pointer] a http pointer
|
|
14
|
+
# @return [Pointer] a http pointer
|
|
15
15
|
def httpConnectEncrypt
|
|
16
16
|
http = Cups::Http.httpConnectEncrypt(hostname, port, Cups.cupsEncryption())
|
|
17
|
-
raise "Print server at #{hostname}:#{port} is not available" if http.null?
|
|
17
|
+
raise ConnectError, "Print server at #{hostname}:#{port} is not available" if http.null?
|
|
18
18
|
return http
|
|
19
19
|
end
|
|
20
20
|
deprecate :httpConnectEncrypt, "This function is deprecated by CUPS, please use httpConnect2 instead", 2025, 12
|
|
@@ -24,7 +24,7 @@ module Cups
|
|
|
24
24
|
# @return [Pointer] a http pointer
|
|
25
25
|
def httpConnect2
|
|
26
26
|
http = Cups::Http.httpConnect2(hostname, port, nil, 0, Cups.cupsEncryption(), 1, 30000, nil)
|
|
27
|
-
raise "Print server at #{hostname}:#{port} is not available" if http.null?
|
|
27
|
+
raise ConnectError, "Print server at #{hostname}:#{port} is not available" if http.null?
|
|
28
28
|
return http
|
|
29
29
|
end
|
|
30
30
|
|
data/lib/ffi-cups/job.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Cups
|
|
|
23
23
|
def cancel(purge=0, connection=nil)
|
|
24
24
|
job = self.class.get_job(@id, @printer, -1, connection)
|
|
25
25
|
r = Cups.cupsCancelJob2(connection, @printer, @id, purge)
|
|
26
|
-
raise Cups.cupsLastErrorString() if r == 0
|
|
26
|
+
raise CupsError, Cups.cupsLastErrorString() if r == 0
|
|
27
27
|
return r
|
|
28
28
|
end
|
|
29
29
|
|
|
@@ -60,7 +60,7 @@ module Cups
|
|
|
60
60
|
jobs.each do |j|
|
|
61
61
|
return j if j.id == id
|
|
62
62
|
end
|
|
63
|
-
raise "Job with id: #{id} not found!"
|
|
63
|
+
raise JobNotFound, "Job with id: #{id} not found!"
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
private
|
|
@@ -75,7 +75,7 @@ module Cups
|
|
|
75
75
|
num_jobs = Cups.cupsGetJobs2(http, pointer, name, 0, filter)
|
|
76
76
|
size = Cups::Struct::Job.size
|
|
77
77
|
jobs = []
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
num_jobs.times do |i|
|
|
80
80
|
job = Cups::Struct::Job.new(pointer.get_pointer(0) + (size * i))
|
|
81
81
|
jobs.push(job)
|
data/lib/ffi-cups/printer.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Cups
|
|
|
34
34
|
#
|
|
35
35
|
# @return [Cups::Job] can be used to check on the job status.
|
|
36
36
|
def print_file(filename, title, options={})
|
|
37
|
-
raise "File not found: #{filename}" unless File.exist? filename
|
|
37
|
+
raise FileNotFound, "File not found: #{filename}" unless File.exist? filename
|
|
38
38
|
|
|
39
39
|
http = @connection.nil? ? nil : @connection.httpConnect2
|
|
40
40
|
with_destination(http) do |dest|
|
|
@@ -55,7 +55,7 @@ module Cups
|
|
|
55
55
|
job_id = Cups.cupsPrintFile2(http, @name, filename, title, num_options, p_options)
|
|
56
56
|
|
|
57
57
|
if job_id == 0
|
|
58
|
-
raise Cups.cupsLastErrorString()
|
|
58
|
+
raise CupsError, Cups.cupsLastErrorString()
|
|
59
59
|
end
|
|
60
60
|
#Cups::Job.new(job_id, title, @name)
|
|
61
61
|
Cups::Job.get_job(job_id, @name, 0, @connection)
|
|
@@ -87,7 +87,7 @@ module Cups
|
|
|
87
87
|
|
|
88
88
|
job_id = Cups.cupsCreateJob(http, @name, title, num_options, p_options)
|
|
89
89
|
if job_id == 0
|
|
90
|
-
raise CupsFFI::cupsLastErrorString()
|
|
90
|
+
raise CupsError, CupsFFI::cupsLastErrorString()
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
# Copy the data into a char pointer to allow null bytes
|
|
@@ -103,7 +103,7 @@ module Cups
|
|
|
103
103
|
|
|
104
104
|
data_pointer.free
|
|
105
105
|
|
|
106
|
-
raise ipp_status.to_s unless ipp_status == :ipp_ok
|
|
106
|
+
raise CupsError, ipp_status.to_s unless ipp_status == :ipp_ok
|
|
107
107
|
|
|
108
108
|
Cups::Job.get_job(job_id, @name, 0, @connection)
|
|
109
109
|
ensure
|
|
@@ -125,7 +125,7 @@ module Cups
|
|
|
125
125
|
# Get the destination from name with cupsGetDest
|
|
126
126
|
p_dest = Cups.cupsGetDest(name, nil, num_dests, dests.get_pointer(0))
|
|
127
127
|
dest = Cups::Struct::Destination.new(p_dest)
|
|
128
|
-
raise "Destination with name: #{name} not found!" if dest.null?
|
|
128
|
+
raise DestinationNotFound, "Destination with name: #{name} not found!" if dest.null?
|
|
129
129
|
yield dest
|
|
130
130
|
ensure
|
|
131
131
|
Cups.cupsFreeDests(num_dests, dests.get_pointer(0))
|
|
@@ -213,12 +213,12 @@ module Cups
|
|
|
213
213
|
def ppd_options
|
|
214
214
|
ppd_path = Cups::Ppd.cupsGetPPD(name)
|
|
215
215
|
if ppd_path.nil? || ppd_path.empty?
|
|
216
|
-
raise "Error: Could not retrieve PPD for printer '#{name}'"
|
|
216
|
+
raise CupsError, "Error: Could not retrieve PPD for printer '#{name}'"
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
ppd_ptr = Cups::Ppd.ppdOpenFile(ppd_path)
|
|
220
220
|
if ppd_ptr.null?
|
|
221
|
-
raise "Error: Failed to open PPD file at #{ppd_path}"
|
|
221
|
+
raise CupsError, "Error: Failed to open PPD file at #{ppd_path}"
|
|
222
222
|
end
|
|
223
223
|
|
|
224
224
|
# Let CUPS evaluate current printer system runtime option defaults
|
data/lib/ffi-cups/version.rb
CHANGED
data/lib/ffi-cups.rb
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
require 'ffi'
|
|
2
2
|
|
|
3
3
|
module Cups
|
|
4
|
+
class Error < RuntimeError
|
|
5
|
+
end
|
|
6
|
+
class FileNotFound < Error
|
|
7
|
+
end
|
|
8
|
+
class JobNotFound < Error
|
|
9
|
+
end
|
|
10
|
+
class ConnectError < Error
|
|
11
|
+
end
|
|
12
|
+
class DestinationNotFound < Error
|
|
13
|
+
end
|
|
14
|
+
class CupsError < Error
|
|
15
|
+
end
|
|
4
16
|
|
|
5
17
|
# Custom or default path for libcups.so
|
|
6
18
|
def self.libcups
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|