thorsson_cups 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/ext/cups.c +23 -0
  2. metadata +2 -2
data/ext/cups.c CHANGED
@@ -411,6 +411,28 @@ static VALUE cups_get_jobs(VALUE self, VALUE printer)
411
411
  return job_list;
412
412
  }
413
413
 
414
+ /*
415
+ * call-seq:
416
+ * Cups.cancel_print(cups_id) -> true or false
417
+ *
418
+ * Cancel the print job. Returns true if successful, false otherwise.
419
+ */
420
+ static VALUE cups_cancel_print(int argc, VALUE* argv, VALUE self, VALUE self)
421
+ {
422
+ VALUE printer, job_id;
423
+ rb_scan_args(argc, argv, "12", &job_id, &printer);
424
+
425
+ if (NIL_P(job_id)) {
426
+ return Qfalse; // If @job_id is nil
427
+ } else { // Otherwise attempt to cancel
428
+ int job = NUM2INT(job_id);
429
+ char *target = RSTRING_PTR(printer); // Target printer string
430
+ int cancellation;
431
+ cancellation = cupsCancelJob(target, job);
432
+ return Qtrue;
433
+ }
434
+ }
435
+
414
436
  /*
415
437
  * call-seq:
416
438
  * Cups.options_for(name) -> Hash or nil
@@ -476,5 +498,6 @@ void Init_cups() {
476
498
  rb_define_singleton_method(rubyCups, "show_destinations", cups_show_dests, 0);
477
499
  rb_define_singleton_method(rubyCups, "default_printer", cups_get_default, 0);
478
500
  rb_define_singleton_method(rubyCups, "all_jobs", cups_get_jobs, 1);
501
+ rb_define_singleton_method(rubyCups, "cancel_print", cups_cancel_print, -1)
479
502
  rb_define_singleton_method(rubyCups, "options_for", cups_get_options, 1);
480
503
  }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 8
9
- version: 0.0.8
8
+ - 9
9
+ version: 0.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ivan Turkovic