ruby-gpgme 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/gpgme_n.c +54 -15
  2. data/lib/gpgme.rb +25 -6
  3. metadata +3 -3
data/gpgme_n.c CHANGED
@@ -1,5 +1,5 @@
1
1
  /* gpgme_n.c -- low level interface to GPGME
2
- Copyright (C) 2003,2006,2007 Daiki Ueno
2
+ Copyright (C) 2003,2006,2007,2008,2009 Daiki Ueno
3
3
 
4
4
  This file is a part of Ruby-GPGME.
5
5
 
@@ -18,19 +18,23 @@ along with GNU Emacs; see the file COPYING. If not, write to the
18
18
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
19
  Boston, MA 02110-1301, USA. */
20
20
 
21
- /* This file is (semi) automatically generated, though it was written
22
- by hand. There are simple rules to edit this file.
21
+ /* While this file was written by hand, it is (semi) automatically
22
+ generated. High-level functions are written in Ruby instead of C
23
+ (See "lib/gpgme.rb"). If you are about to edit this file, you may
24
+ want to check out the translation rules:
23
25
 
24
- 1. Each symbol exported from this module is either a class, a module
25
- function, or a constant. No instance methods are defined here.
26
- 2. Each symbol exported from this module follows the same naming
27
- convention as the GPGME API. That is, symbol names are followed
28
- by `gpgme_' for functions are followed by `GPGME_' or `GPG_' for
29
- constants.
30
- 3. Output arguments are wrapped in arrays. For example, the 1st
31
- argument of `gpgme_data_new' has type `gpgme_data_t *' to store the
32
- newly created gpgme_data_t object. The corresponding ruby
33
- interface uses an empty array to passing it to the caller. */
26
+ 1. Each symbol defined in this file is either a class, a module
27
+ function, or a constant. _No instance methods are defined here_.
28
+
29
+ 2. Each symbol defined in this file follows the same naming convention
30
+ as the GPGME API. That is, symbol names are followed by `gpgme_'
31
+ for functions, and `GPGME_' or `GPG_' for constants.
32
+
33
+ 3. Output arguments are wrapped in arrays. For example, the first
34
+ argument of `gpgme_data_new' has the type `gpgme_data_t *', and to
35
+ be used to hold a newly created gpgme_data_t object. The
36
+ corresponding Ruby interface expects an array (empty for typical
37
+ cases) for that. */
34
38
 
35
39
  #include "ruby.h"
36
40
  #include "gpgme.h"
@@ -139,11 +143,12 @@ rb_s_gpgme_get_engine_info (VALUE dummy, VALUE rinfo)
139
143
  {
140
144
  gpgme_engine_info_t info;
141
145
  gpgme_error_t err;
146
+ long idx;
142
147
 
143
148
  err = gpgme_get_engine_info (&info);
144
149
  if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
145
150
  {
146
- for (; info; info = info->next)
151
+ for (idx = 0; info; info = info->next, idx++)
147
152
  {
148
153
  VALUE vinfo = rb_class_new_instance (0, NULL, cEngineInfo);
149
154
  rb_iv_set (vinfo, "@protocol", INT2FIX(info->protocol));
@@ -153,12 +158,26 @@ rb_s_gpgme_get_engine_info (VALUE dummy, VALUE rinfo)
153
158
  rb_iv_set (vinfo, "@version", rb_str_new2 (info->version));
154
159
  if (info->req_version)
155
160
  rb_iv_set (vinfo, "@req_version", rb_str_new2 (info->req_version));
156
- rb_ary_store (rinfo, 0, vinfo);
161
+ if (info->home_dir)
162
+ rb_iv_set (vinfo, "@home_dir", rb_str_new2 (info->home_dir));
163
+ rb_ary_store (rinfo, idx, vinfo);
157
164
  }
158
165
  }
159
166
  return LONG2NUM(err);
160
167
  }
161
168
 
169
+ static VALUE
170
+ rb_s_gpgme_set_engine_info (VALUE dummy, VALUE vproto, VALUE vfile_name,
171
+ VALUE vhome_dir)
172
+ {
173
+ gpgme_error_t err = gpgme_set_engine_info (NUM2INT(vproto),
174
+ NIL_P(vfile_name) ? NULL :
175
+ StringValueCStr(vfile_name),
176
+ NIL_P(vhome_dir) ? NULL :
177
+ StringValueCStr(vhome_dir));
178
+ return LONG2NUM(err);
179
+ }
180
+
162
181
  static VALUE
163
182
  rb_s_gpgme_pubkey_algo_name (VALUE dummy, VALUE valgo)
164
183
  {
@@ -1183,6 +1202,12 @@ rb_s_gpgme_op_verify_result (VALUE dummy, VALUE vctx)
1183
1202
  rb_iv_set (vsignature, "@validity", INT2FIX(signature->validity));
1184
1203
  rb_iv_set (vsignature, "@validity_reason",
1185
1204
  LONG2NUM(signature->validity_reason));
1205
+ /* PKA related fields were added in 1.1.1. */
1206
+ #ifdef GPGME_STATUS_PKA_TRUST_BAD
1207
+ rb_iv_set (vsignature, "@pka_trust", INT2FIX(signature->pka_trust));
1208
+ rb_iv_set (vsignature, "@pka_address",
1209
+ rb_str_new2 (signature->pka_address));
1210
+ #endif
1186
1211
  rb_ary_push (vsignatures, vsignature);
1187
1212
  }
1188
1213
  return vverify_result;
@@ -1532,6 +1557,8 @@ Init_gpgme_n (void)
1532
1557
  rb_s_gpgme_engine_check_version, 1);
1533
1558
  rb_define_module_function (mGPGME, "gpgme_get_engine_info",
1534
1559
  rb_s_gpgme_get_engine_info, 1);
1560
+ rb_define_module_function (mGPGME, "gpgme_set_engine_info",
1561
+ rb_s_gpgme_set_engine_info, 3);
1535
1562
 
1536
1563
  rb_define_module_function (mGPGME, "gpgme_pubkey_algo_name",
1537
1564
  rb_s_gpgme_pubkey_algo_name, 1);
@@ -2140,6 +2167,13 @@ Init_gpgme_n (void)
2140
2167
  INT2FIX(GPGME_STATUS_TRUNCATED));
2141
2168
  rb_define_const (mGPGME, "GPGME_STATUS_ERROR",
2142
2169
  INT2FIX(GPGME_STATUS_ERROR));
2170
+ /* These status codes have been available since 1.1.1. */
2171
+ #ifdef GPGME_STATUS_PKA_TRUST_BAD
2172
+ rb_define_const (mGPGME, "GPGME_STATUS_PKA_TRUST_BAD",
2173
+ INT2FIX(GPGME_STATUS_PKA_TRUST_BAD));
2174
+ rb_define_const (mGPGME, "GPGME_STATUS_PKA_TRUST_GOOD",
2175
+ INT2FIX(GPGME_STATUS_PKA_TRUST_GOOD));
2176
+ #endif
2143
2177
 
2144
2178
  /* The available keylist mode flags. */
2145
2179
  rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_LOCAL",
@@ -2148,6 +2182,11 @@ Init_gpgme_n (void)
2148
2182
  INT2FIX(GPGME_KEYLIST_MODE_EXTERN));
2149
2183
  rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_SIGS",
2150
2184
  INT2FIX(GPGME_KEYLIST_MODE_SIGS));
2185
+ /* This flag was added in 1.1.1. */
2186
+ #ifdef GPGME_KEYLIST_MODE_SIG_NOTATIONS
2187
+ rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_SIG_NOTATIONS",
2188
+ INT2FIX(GPGME_KEYLIST_MODE_SIG_NOTATIONS));
2189
+ #endif
2151
2190
  rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_VALIDATE",
2152
2191
  INT2FIX(GPGME_KEYLIST_MODE_VALIDATE));
2153
2192
 
data/lib/gpgme.rb CHANGED
@@ -72,7 +72,7 @@ level API.
72
72
 
73
73
  = License
74
74
 
75
- Copyright (C) 2003,2006 Daiki Ueno
75
+ Copyright (C) 2003,2006,2007,2008,2009 Daiki Ueno
76
76
 
77
77
  This file is a part of Ruby-GPGME.
78
78
 
@@ -715,12 +715,16 @@ module GPGME
715
715
  alias hash_algo_name gpgme_hash_algo_name
716
716
  end
717
717
 
718
- def engine_check_version
719
- err = GPGME::gpgme_engine_check_version
718
+ # Verify that the engine implementing the protocol <i>proto</i> is
719
+ # installed in the system.
720
+ def engine_check_version(proto)
721
+ err = GPGME::gpgme_engine_check_version(proto)
720
722
  exc = GPGME::error_to_exception(err)
721
723
  raise exc if exc
722
724
  end
725
+ module_function :engine_check_version
723
726
 
727
+ # Return a list of info structures of enabled engines.
724
728
  def engine_info
725
729
  rinfo = Array.new
726
730
  GPGME::gpgme_get_engine_info(rinfo)
@@ -728,6 +732,19 @@ module GPGME
728
732
  end
729
733
  module_function :engine_info
730
734
 
735
+ # Change the default configuration of the crypto engine implementing
736
+ # protocol <i>proto</i>.
737
+ #
738
+ # <i>file_name</i> is the file name of the executable program
739
+ # implementing the protocol.
740
+ # <i>home_dir</i> is the directory name of the configuration directory.
741
+ def set_engine_info(proto, file_name, home_dir)
742
+ err = GPGME::gpgme_set_engine_info(proto, file_name, home_dir)
743
+ exc = GPGME::error_to_exception(err)
744
+ raise exc if exc
745
+ end
746
+ module_function :set_engine_info
747
+
731
748
  # A class for managing data buffers.
732
749
  class Data
733
750
  BLOCK_SIZE = 4096
@@ -835,7 +852,7 @@ module GPGME
835
852
  class EngineInfo
836
853
  private_class_method :new
837
854
 
838
- attr_reader :protocol, :file_name, :version, :req_version
855
+ attr_reader :protocol, :file_name, :version, :req_version, :home_dir
839
856
  alias required_version req_version
840
857
  end
841
858
 
@@ -958,7 +975,7 @@ keylist_mode=#{KEYLIST_MODE_NAMES[keylist_mode]}>"
958
975
  # (0 ... $_.length).each do |i| $_[i] = ?0 end if $_
959
976
  # system('stty echo')
960
977
  # end
961
- # puts
978
+ # $stderr.puts
962
979
  # end
963
980
  #
964
981
  # ctx.set_passphrase_callback(method(:passfunc))
@@ -1379,7 +1396,9 @@ validity=#{VALIDITY_NAMES[validity]}, signatures=#{signatures.inspect}>"
1379
1396
  class Signature
1380
1397
  private_class_method :new
1381
1398
 
1382
- attr_reader :summary, :fpr, :status, :notations
1399
+ attr_reader :summary, :fpr, :status, :notations, :wrong_key_usage
1400
+ attr_reader :validity, :validity_reason
1401
+ attr_reader :pka_trust, :pka_address
1383
1402
  alias fingerprint fpr
1384
1403
 
1385
1404
  def timestamp
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gpgme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daiki Ueno
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-30 00:00:00 +09:00
12
+ date: 2009-01-19 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  requirements: []
59
59
 
60
60
  rubyforge_project: ruby-gpgme
61
- rubygems_version: 1.2.0
61
+ rubygems_version: 1.3.1
62
62
  signing_key:
63
63
  specification_version: 2
64
64
  summary: Ruby binding of GPGME.