(Ctx#genkey): Take data objects.

This commit is contained in:
Daiki Ueno 2006-10-17 10:59:56 +00:00
Родитель b452110a25
Коммит dd3c1f8eaa
3 изменённых файлов: 22 добавлений и 18 удалений

Просмотреть файл

@ -18,7 +18,13 @@ passphrase_cb = proc {|hook, uid_hint, passphrase_info, prev_was_bad, fd|
}
ctx.set_passphrase_cb(passphrase_cb)
pair = ctx.genkey(<<'EOF')
progress_cb = proc {|hook, what, type, current, total|
$stderr.write("#{what}: #{current}/#{total}\r")
$stderr.flush
}
ctx.set_progress_cb(progress_cb)
ctx.genkey(<<'EOF', nil, nil)
<GnupgKeyParms format="internal">
Key-Type: DSA
Key-Length: 1024
@ -27,10 +33,8 @@ Subkey-Length: 1024
Name-Real: Joe Tester
Name-Comment: with stupid passphrase
Name-Email: joe@foo.bar
Passphrase: abcdabcdfs
Expire-Date: 2010-08-15
Expire-Date: 0
Passphrase: abc
</GnupgKeyParms>
EOF
puts("Pubkey:\n#{pair[0].read}")
puts("Seckey:\n#{pair[1].read}")
$stderr.puts

Просмотреть файл

@ -213,7 +213,7 @@ rb_s_gpgme_data_new_from_mem (dummy, rdh, vbuffer, vsize, vcopy)
if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
{
vdh = WRAP_GPGME_DATA(dh);
/* Keep a references to VBUFFER to avoid GC. */
/* Keep a reference to VBUFFER to avoid GC. */
rb_iv_set (vdh, "@buffer", vbuffer);
rb_ary_push (rdh, vdh);
}
@ -325,7 +325,7 @@ rb_s_gpgme_data_new_from_cbs (dummy, rdh, vcbs, vhandle)
if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
{
VALUE vdh = WRAP_GPGME_DATA(dh);
/* Keep a references to avoid GC. */
/* Keep a reference to avoid GC. */
rb_iv_set (vdh, "@cbs_handle", vcbs_handle);
rb_ary_push (rdh, vdh);
}
@ -617,7 +617,7 @@ rb_s_gpgme_set_passphrase_cb (dummy, vctx, vpassfunc, vhook_value)
rb_ary_push (vcb, vpassfunc);
rb_ary_push (vcb, vhook_value);
/* Keep a references to avoid GC. */
/* Keep a reference to avoid GC. */
rb_iv_set (vctx, "@passphrase_cb", vcb);
UNWRAP_GPGME_CTX(vctx, ctx);
@ -648,8 +648,9 @@ progress_cb (hook, what, type, current, total)
vprogfunc = RARRAY(vcb)->ptr[0];
vhook_value = RARRAY(vcb)->ptr[1];
rb_funcall (vprogfunc, rb_intern ("call"), 5, vhook_value, INT2NUM(type),
INT2NUM(current), INT2NUM(total));
rb_funcall (vprogfunc, rb_intern ("call"), 5, vhook_value,
rb_str_new2 (what), INT2NUM(type), INT2NUM(current),
INT2NUM(total));
}
static VALUE
@ -661,11 +662,11 @@ rb_s_gpgme_set_progress_cb (dummy, vctx, vprogfunc, vhook_value)
rb_ary_push (vcb, vprogfunc);
rb_ary_push (vcb, vhook_value);
/* Keep a references to avoid GC. */
/* Keep a reference to avoid GC. */
rb_iv_set (vctx, "@progress_cb", vcb);
UNWRAP_GPGME_CTX(vctx, ctx);
gpgme_set_progress_cb (ctx, progress_cb, (void*)vctx);
gpgme_set_progress_cb (ctx, progress_cb, (void*)vcb);
return Qnil;
}

Просмотреть файл

@ -341,7 +341,7 @@ keylist_mode=#{KEYLIST_MODE_NAMES[keylist_mode]}>"
GPGME::gpgme_set_progress_cb(self, progfunc, hook_value)
end
# Initiates a key listing operation for given pattern.
# Initiate a key listing operation for given pattern.
# If pattern is nil, all available keys are returned.
# If secret_only is true, the list is restricted to secret keys only.
def keylist_start(pattern = nil, secret_only = false)
@ -350,7 +350,7 @@ keylist_mode=#{KEYLIST_MODE_NAMES[keylist_mode]}>"
raise exc if exc
end
# Returns the next key in the list created by a previous
# Return the next key in the list created by a previous
# keylist_start operation.
def keylist_next
rkey = Array.new
@ -411,7 +411,6 @@ keylist_mode=#{KEYLIST_MODE_NAMES[keylist_mode]}>"
err = GPGME::gpgme_op_genkey(self, parms, pubkey, seckey)
exc = GPGME::error_to_exception(err)
raise exc if exc
[pubkey, seckey]
end
alias generate_key genkey
@ -422,7 +421,7 @@ keylist_mode=#{KEYLIST_MODE_NAMES[keylist_mode]}>"
end
alias generate_key_start genkey_start
# Extracts the public keys of the recipients.
# Extract the public keys of the recipients.
def export(recipients)
keydata = Data.new
err = GPGME::gpgme_op_export(self, recipients, keydata)
@ -479,7 +478,7 @@ keylist_mode=#{KEYLIST_MODE_NAMES[keylist_mode]}>"
plain
end
# Removes the list of signers from this object.
# Remove the list of signers from this object.
def clear_signers
GPGME::gpgme_signers_clear(self)
end