thorsson_cups 0.0.15 → 0.0.16

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.
Files changed (2) hide show
  1. data/ext/cups.c +7 -62
  2. metadata +2 -2
data/ext/cups.c CHANGED
@@ -146,67 +146,13 @@ static VALUE cups_print(VALUE self)
146
146
  }
147
147
 
148
148
  if(NIL_P(url)) {
149
- job_id = cupsPrintFile(target, fname, "rCups", num_options, options); // Do it. "rCups" should be the filename/path
149
+ url = cupsServer();
150
150
  }
151
- else {
152
- int encryption = (http_encryption_t)cupsEncryption();
153
- http = httpConnectEncrypt (url, port, (http_encryption_t) encryption);
154
- job_id = cupsPrintFile2(http, target, fname, "rCups", num_options, options); // Do it. "rCups" should be the filename/path
155
- }
156
- cupsFreeOptions(num_options, options);
157
-
158
- rb_iv_set(self, "@job_id", INT2NUM(job_id));
159
-
160
- return Qtrue;
161
- }
162
-
163
- /*
164
- * call-seq:
165
- * print_job.web_print -> Fixnum
166
- *
167
- * Submit a print job from URL to the selected printer or class. Returns true on success.
168
- */
169
- static VALUE cups_web_print(VALUE self)
170
- {
171
- int job_id;
172
- VALUE file = rb_iv_get(self, "@filename");
173
- VALUE printer = rb_iv_get(self, "@printer");
174
- VALUE url_path = rb_iv_get(self, "@url_path");
175
-
176
- char *fname = RSTRING_PTR(file); // Filename
177
- char *target = RSTRING_PTR(printer); // Target printer string
178
- char *url = RSTRING_PTR(url_path); // URL path for web file
179
-
180
- VALUE job_options = rb_iv_get(self, "@job_options");
181
-
182
- // Create an array of the keys from the job_options hash
183
- VALUE job_options_keys = rb_ary_new();
184
- rb_hash_foreach(job_options, cups_keys_i, job_options_keys);
185
-
186
- VALUE iter;
187
- int num_options = 0;
188
- cups_option_t *options = NULL;
189
-
190
- // foreach option in the job options array
191
- while (! NIL_P(iter = rb_ary_pop(job_options_keys))) {
192
-
193
- VALUE value = rb_hash_aref(job_options, iter);
194
-
195
- // assert the key and value are strings
196
- if (NIL_P(rb_check_string_type(iter)) || NIL_P(rb_check_string_type(value))) {
197
- cupsFreeOptions(num_options, options);
198
- rb_raise(rb_eTypeError, "job options is not string => string hash");
199
- return Qfalse;
200
- }
201
-
202
- // convert to char pointers and add to cups optoins
203
- char * iter_str = rb_string_value_ptr(&iter);
204
- char * value_str = rb_string_value_ptr(&value);
205
- cupsAddOption(iter_str, value_str, num_options++, &options);
206
- }
207
-
208
- job_id = cupsPrintFile(url, target, fname, "cloudomat", num_options, options); // Do it. "rCups" should be the filename/path
209
-
151
+
152
+ int encryption = (http_encryption_t)cupsEncryption();
153
+ http_t *http = httpConnectEncrypt (url, port, (http_encryption_t) encryption);
154
+ job_id = cupsPrintFile2(http, target, fname, "rCups", num_options, options); // Do it. "rCups" should be the filename/path
155
+
210
156
  cupsFreeOptions(num_options, options);
211
157
 
212
158
  rb_iv_set(self, "@job_id", INT2NUM(job_id));
@@ -534,14 +480,13 @@ void Init_cups() {
534
480
  // Cups::PrintJob Attributes
535
481
  rb_define_attr(printJobs, "printer", 1, 0);
536
482
  rb_define_attr(printJobs, "filename", 1, 0);
537
- rb_define_attr(printJobs, "url_path", 1, 0)
483
+ rb_define_attr(printJobs, "url_path", 1, 0);
538
484
  rb_define_attr(printJobs, "job_id", 1, 0);
539
485
  rb_define_attr(printJobs, "job_options", 1, 0);
540
486
 
541
487
  // Cups::PrintJob Methods
542
488
  rb_define_method(printJobs, "initialize", job_init, -1);
543
489
  rb_define_method(printJobs, "print", cups_print, 0);
544
- rb_define_method(printJobs, "web_print", cups_web_print, 0);
545
490
  rb_define_method(printJobs, "cancel", cups_cancel, 0);
546
491
  rb_define_method(printJobs, "state", cups_get_job_state, 0);
547
492
  rb_define_method(printJobs, "completed?", cups_job_completed, 0);
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 15
9
- version: 0.0.15
8
+ - 16
9
+ version: 0.0.16
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ivan Turkovic