gphoto4ruby 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +9 -0
- data/ext/gphoto2camera.c +116 -79
- data/ext/gphoto2camera.h +1 -0
- data/ext/gphoto4ruby.c +1 -0
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.2.4
|
2
|
+
|
3
|
+
* fixed memory allocation bug with CameraFilePath pointer
|
4
|
+
|
5
|
+
== 0.2.3
|
6
|
+
|
7
|
+
* fixed bug where :no_cache directive had no effect on config caching
|
8
|
+
* added create_folder function
|
9
|
+
|
1
10
|
== 0.2.2
|
2
11
|
|
3
12
|
* fixed bug where event "file added" was not changing file path
|
data/ext/gphoto2camera.c
CHANGED
@@ -31,6 +31,7 @@ void camera_free(GPhoto2Camera *c) {
|
|
31
31
|
gp_result_check(gp_list_free(c->list));
|
32
32
|
gp_result_check(gp_file_free(c->file));
|
33
33
|
gp_result_check(gp_camera_free(c->camera));
|
34
|
+
free(c->path);
|
34
35
|
free(c->virtFolder);
|
35
36
|
free(c->context);
|
36
37
|
free(c);
|
@@ -39,7 +40,8 @@ void camera_free(GPhoto2Camera *c) {
|
|
39
40
|
VALUE camera_allocate(VALUE klass) {
|
40
41
|
GPhoto2Camera *c;
|
41
42
|
c = (GPhoto2Camera*) malloc(sizeof(GPhoto2Camera));
|
42
|
-
c->virtFolder = (char*) malloc(sizeof(char)*
|
43
|
+
c->virtFolder = (char*) malloc(sizeof(char)*1024);
|
44
|
+
c->path = (CameraFilePath*) malloc(sizeof(CameraFilePath));
|
43
45
|
strcpy(c->virtFolder, "/");
|
44
46
|
c->context = gp_context_new();
|
45
47
|
gp_result_check(gp_camera_new(&(c->camera)));
|
@@ -198,8 +200,8 @@ VALUE camera_capture(int argc, VALUE *argv, VALUE self) {
|
|
198
200
|
}
|
199
201
|
|
200
202
|
gp_result_check(gp_camera_capture(c->camera, GP_CAPTURE_IMAGE, c->path, c->context));
|
203
|
+
printf("captured: %s/%s\n", c->path->folder, c->path->name);
|
201
204
|
strcpy(c->virtFolder, c->path->folder);
|
202
|
-
// printf("captured: %s/%s\n", c->path.folder, c->path.name);
|
203
205
|
return self;
|
204
206
|
}
|
205
207
|
|
@@ -548,20 +550,9 @@ VALUE camera_get_value(int argc, VALUE *argv, VALUE self) {
|
|
548
550
|
GPhoto2Camera *c;
|
549
551
|
CameraWidgetType widgettype;
|
550
552
|
VALUE str, dir;
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
str = argv[0];
|
555
|
-
break;
|
556
|
-
case 2:
|
557
|
-
str = argv[0];
|
558
|
-
dir = argv[1];
|
559
|
-
Check_Type(dir, T_SYMBOL);
|
560
|
-
break;
|
561
|
-
default:
|
562
|
-
rb_raise(rb_eArgError, "Wrong number of arguments (%d for 1 or 2)", argc);
|
563
|
-
return Qnil;
|
564
|
-
}
|
553
|
+
VALUE val;
|
554
|
+
|
555
|
+
str = argv[0];
|
565
556
|
|
566
557
|
switch (TYPE(str)) {
|
567
558
|
case T_STRING:
|
@@ -574,70 +565,90 @@ VALUE camera_get_value(int argc, VALUE *argv, VALUE self) {
|
|
574
565
|
rb_raise(rb_eTypeError, "Not valid parameter type");
|
575
566
|
return Qnil;
|
576
567
|
}
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
568
|
+
|
569
|
+
switch (argc) {
|
570
|
+
case 1:
|
571
|
+
return rb_hash_aref(rb_iv_get(self, "@configuration"), rb_str_new2(name));
|
572
|
+
break;
|
573
|
+
case 2:
|
574
|
+
dir = argv[1];
|
575
|
+
Check_Type(dir, T_SYMBOL);
|
576
|
+
Data_Get_Struct(self, GPhoto2Camera, c);
|
577
|
+
|
578
|
+
if (strcmp(rb_id2name(rb_to_id(dir)), "no_cache") == 0) {
|
579
|
+
gp_result_check(gp_camera_get_config(c->camera, &(c->config), c->context));
|
580
|
+
}
|
581
|
+
|
582
|
+
gp_result_check(gp_widget_get_child_by_name(c->config, name, &(c->childConfig)));
|
583
|
+
gp_result_check(gp_widget_get_type(c->childConfig, &widgettype));
|
584
|
+
switch (widgettype) {
|
585
|
+
case GP_WIDGET_RADIO:
|
586
|
+
if (strcmp(rb_id2name(rb_to_id(dir)), "no_cache") == 0) {
|
587
|
+
val = getRadio(c->childConfig);
|
588
|
+
rb_hash_aset(rb_iv_get(self, "@configuration"), rb_str_new2(name), val);
|
589
|
+
return val;
|
590
|
+
} else if (strcmp(rb_id2name(rb_to_id(dir)), "all") == 0) {
|
591
|
+
return listRadio(c->childConfig);
|
592
|
+
} else if (strcmp(rb_id2name(rb_to_id(dir)), "type") == 0) {
|
593
|
+
return INT2FIX(GP_WIDGET_RADIO);
|
594
|
+
} else {
|
595
|
+
rb_raise(rb_cGPhoto2ConfigurationError, "Unknown directive '%s'", rb_id2name(rb_to_id(dir)));
|
596
|
+
return Qnil;
|
597
|
+
}
|
598
|
+
break;
|
599
|
+
case GP_WIDGET_TEXT:
|
600
|
+
if (strcmp(rb_id2name(rb_to_id(dir)), "no_cache") == 0) {
|
601
|
+
val = getText(c->childConfig);
|
602
|
+
rb_hash_aset(rb_iv_get(self, "@configuration"), rb_str_new2(name), val);
|
603
|
+
return val;
|
604
|
+
} else if (strcmp(rb_id2name(rb_to_id(dir)), "all") == 0) {
|
605
|
+
return rb_ary_new();
|
606
|
+
} else if (strcmp(rb_id2name(rb_to_id(dir)), "type") == 0) {
|
607
|
+
return INT2FIX(GP_WIDGET_TEXT);
|
608
|
+
} else {
|
609
|
+
rb_raise(rb_cGPhoto2ConfigurationError, "Unknown directive '%s'", rb_id2name(rb_to_id(dir)));
|
610
|
+
return Qnil;
|
611
|
+
}
|
612
|
+
break;
|
613
|
+
case GP_WIDGET_RANGE:
|
614
|
+
if (strcmp(rb_id2name(rb_to_id(dir)), "no_cache") == 0) {
|
615
|
+
val = getRange(c->childConfig);
|
616
|
+
rb_hash_aset(rb_iv_get(self, "@configuration"), rb_str_new2(name), val);
|
617
|
+
return val;
|
618
|
+
} else if (strcmp(rb_id2name(rb_to_id(dir)), "all") == 0) {
|
619
|
+
return listRange(c->childConfig);
|
620
|
+
} else if (strcmp(rb_id2name(rb_to_id(dir)), "type") == 0) {
|
621
|
+
return INT2FIX(GP_WIDGET_RANGE);
|
622
|
+
} else {
|
623
|
+
rb_raise(rb_cGPhoto2ConfigurationError, "Unknown directive '%s'", rb_id2name(rb_to_id(dir)));
|
624
|
+
return Qnil;
|
625
|
+
}
|
626
|
+
break;
|
627
|
+
case GP_WIDGET_TOGGLE:
|
628
|
+
if (strcmp(rb_id2name(rb_to_id(dir)), "no_cache") == 0) {
|
629
|
+
val = getToggle(c->childConfig);
|
630
|
+
rb_hash_aset(rb_iv_get(self, "@configuration"), rb_str_new2(name), val);
|
631
|
+
return val;
|
632
|
+
} else if (strcmp(rb_id2name(rb_to_id(dir)), "all") == 0) {
|
633
|
+
VALUE arr = rb_ary_new();
|
634
|
+
rb_ary_push(arr, Qtrue);
|
635
|
+
rb_ary_push(arr, Qfalse);
|
636
|
+
return arr;
|
637
|
+
} else if (strcmp(rb_id2name(rb_to_id(dir)), "type") == 0) {
|
638
|
+
return INT2FIX(GP_WIDGET_TOGGLE);
|
639
|
+
} else {
|
640
|
+
rb_raise(rb_cGPhoto2ConfigurationError, "Unknown directive '%s'", rb_id2name(rb_to_id(dir)));
|
641
|
+
return Qnil;
|
642
|
+
}
|
643
|
+
break;
|
644
|
+
default:
|
645
|
+
rb_raise(rb_cGPhoto2ConfigurationError, "Not supported yet");
|
634
646
|
return Qnil;
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
}
|
647
|
+
}
|
648
|
+
break;
|
649
|
+
default:
|
650
|
+
rb_raise(rb_eArgError, "Wrong number of arguments (%d for 1 or 2)", argc);
|
651
|
+
return Qnil;
|
641
652
|
}
|
642
653
|
}
|
643
654
|
|
@@ -867,6 +878,32 @@ VALUE camera_folder_down(VALUE self, VALUE folder) {
|
|
867
878
|
return self;
|
868
879
|
}
|
869
880
|
|
881
|
+
/*
|
882
|
+
* call-seq:
|
883
|
+
* create_folder(name) => camera
|
884
|
+
*
|
885
|
+
* Creates subfolder in current camera path with specified name. If not
|
886
|
+
* supported by camera throws "Unspecified error" GPhoto2::Exception
|
887
|
+
*
|
888
|
+
* Examples:
|
889
|
+
*
|
890
|
+
* c = GPhoto2::Camera.new
|
891
|
+
* c.create_folder "my_store"
|
892
|
+
*
|
893
|
+
*/
|
894
|
+
VALUE camera_create_folder(VALUE self, VALUE folder) {
|
895
|
+
Check_Type(folder, T_STRING);
|
896
|
+
|
897
|
+
const char *name;
|
898
|
+
GPhoto2Camera *c;
|
899
|
+
|
900
|
+
Data_Get_Struct(self, GPhoto2Camera, c);
|
901
|
+
|
902
|
+
name = RSTRING(folder)->ptr;
|
903
|
+
gp_result_check(gp_camera_folder_make_dir(c->camera, c->virtFolder, name, c->context));
|
904
|
+
return self;
|
905
|
+
}
|
906
|
+
|
870
907
|
/*
|
871
908
|
* call-seq:
|
872
909
|
* wait(timeout=2000) => camera event
|
data/ext/gphoto2camera.h
CHANGED
@@ -60,6 +60,7 @@ VALUE camera_subfolders(VALUE self);
|
|
60
60
|
VALUE camera_files(VALUE self);
|
61
61
|
VALUE camera_folder_up(VALUE self);
|
62
62
|
VALUE camera_folder_down(VALUE self, VALUE folder);
|
63
|
+
VALUE camera_create_folder(VALUE self, VALUE folder);
|
63
64
|
|
64
65
|
VALUE camera_wait(int argc, VALUE *argv, VALUE self);
|
65
66
|
|
data/ext/gphoto4ruby.c
CHANGED
@@ -82,6 +82,7 @@ void Init_gphoto4ruby() {
|
|
82
82
|
rb_define_method(rb_cGPhoto2Camera, "files", camera_files, 0); /* in gphoto2camera.c */
|
83
83
|
rb_define_method(rb_cGPhoto2Camera, "folder_up", camera_folder_up, 0); /* in gphoto2camera.c */
|
84
84
|
rb_define_method(rb_cGPhoto2Camera, "folder_down", camera_folder_down, 1); /* in gphoto2camera.c */
|
85
|
+
rb_define_method(rb_cGPhoto2Camera, "create_folder", camera_create_folder, 1); /* in gphoto2camera.c */
|
85
86
|
rb_define_method(rb_cGPhoto2Camera, "wait", camera_wait, -1); /* in gphoto2camera.c */
|
86
87
|
|
87
88
|
rb_define_method(rb_cGPhoto2CameraEvent, "type", camera_event_type, 0); /* in gphoto2camera_event.c */
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gphoto4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- heq4 company
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-
|
13
|
+
date: 2008-10-06 00:00:00 +04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|