@item GPGME_KEYLIST_MODE_EXTERN
The @code{GPGME_KEYLIST_MODE_EXTERN} symbol specifies that an external
-source should be searched for keys in the keylisting
-operation. The type of external source is dependant on the crypto
-engine used. For example, it can be a remote keyserver or LDAP
-certificate server.
+source should be searched for keys in the keylisting operation. The
+type of external source is dependant on the crypto engine used and
+whether it is combined with @code{GPGME_KEYLIST_MODE_LOCAL}. For
+example, it can be a remote keyserver or LDAP certificate server.
@item GPGME_KEYLIST_MODE_SIGS
The @code{GPGME_KEYLIST_MODE_SIGS} symbol specifies that the key
@code{GPGME_KEYLIST_MODE_EXTERN} must be specified. For future binary
compatibility, you should get the current mode with
@code{gpgme_get_keylist_mode} and modify it by setting or clearing the
-appropriate bits, and then using that calulcated value in the
+appropriate bits, and then using that calculated value in the
@code{gpgme_set_keylisting_mode} operation. This will leave all other
bits in the mode value intact (in particular those that are not used
in the current version of the library).
rc = gpg_error_from_errno (errno);
else
{
- if (dft_ttyname)
+ if (*dft_ttyname)
{
rc = add_arg (gpg, "--ttyname");
if (!rc)
}
-static gpgme_error_t
-gpg_keylist (void *engine, const char *pattern, int secret_only,
- gpgme_keylist_mode_t mode)
+static gpg_error_t
+gpg_keylist_build_options (engine_gpg_t gpg, int secret_only,
+ gpgme_keylist_mode_t mode)
{
- engine_gpg_t gpg = engine;
- gpgme_error_t err;
+ gpg_error_t err;
- if (mode & GPGME_KEYLIST_MODE_EXTERN)
- {
- if ((mode & GPGME_KEYLIST_MODE_LOCAL)
- || secret_only)
- return gpg_error (GPG_ERR_NOT_SUPPORTED);
- }
-
err = add_arg (gpg, "--with-colons");
if (!err)
err = add_arg (gpg, "--fixed-list-mode");
err = add_arg (gpg, "--with-fingerprint");
if (!err)
err = add_arg (gpg, "--with-fingerprint");
- if (!err && (mode & GPGME_KEYLIST_MODE_SIGS)
+ if (!err
+ && (mode & GPGME_KEYLIST_MODE_SIGS)
&& (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS))
{
err = add_arg (gpg, "--list-options");
}
if (!err)
{
- if (mode & GPGME_KEYLIST_MODE_EXTERN)
+ if ( (mode & GPGME_KEYLIST_MODE_EXTERN) )
{
- err = add_arg (gpg, "--search-keys");
- gpg->colon.preprocess_fnc = gpg_keylist_preprocess;
+ if (secret_only)
+ err = gpg_error (GPG_ERR_NOT_SUPPORTED);
+ else if ( (mode & GPGME_KEYLIST_MODE_LOCAL))
+ {
+ /* The local+extern mode is special. It works only with
+ gpg >= 2.0.10. FIXME: We should check that we have
+ such a version to that we can return a proper error
+ code. The problem is that we don't know the context
+ here and thus can't accesses the cached version
+ number for the engine info structure. */
+ err = add_arg (gpg, "--locate-keys");
+ if ((mode & GPGME_KEYLIST_MODE_SIGS))
+ err = add_arg (gpg, "--with-sig-check");
+ }
+ else
+ {
+ err = add_arg (gpg, "--search-keys");
+ gpg->colon.preprocess_fnc = gpg_keylist_preprocess;
+ }
}
else
- {
- err = add_arg (gpg, secret_only ? "--list-secret-keys"
- : ((mode & GPGME_KEYLIST_MODE_SIGS)
- ? "--check-sigs" : "--list-keys"));
- }
+ {
+ err = add_arg (gpg, secret_only ? "--list-secret-keys"
+ : ((mode & GPGME_KEYLIST_MODE_SIGS)
+ ? "--check-sigs" : "--list-keys"));
+ }
}
-
- /* Tell the gpg object about the data. */
if (!err)
err = add_arg (gpg, "--");
+
+ return err;
+}
+
+
+static gpgme_error_t
+gpg_keylist (void *engine, const char *pattern, int secret_only,
+ gpgme_keylist_mode_t mode)
+{
+ engine_gpg_t gpg = engine;
+ gpgme_error_t err;
+
+ err = gpg_keylist_build_options (gpg, secret_only, mode);
+
if (!err && pattern && *pattern)
err = add_arg (gpg, pattern);
if (reserved)
return gpg_error (GPG_ERR_INV_VALUE);
- err = add_arg (gpg, "--with-colons");
- if (!err)
- err = add_arg (gpg, "--fixed-list-mode");
- if (!err)
- err = add_arg (gpg, "--with-fingerprint");
- if (!err)
- err = add_arg (gpg, "--with-fingerprint");
- if (!err && (mode & GPGME_KEYLIST_MODE_SIGS)
- && (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS))
- {
- err = add_arg (gpg, "--list-options");
- if (!err)
- err = add_arg (gpg, "show-sig-subpackets=\"20,26\"");
- }
- if (!err)
- err = add_arg (gpg, secret_only ? "--list-secret-keys"
- : ((mode & GPGME_KEYLIST_MODE_SIGS)
- ? "--check-sigs" : "--list-keys"));
- if (!err)
- err = add_arg (gpg, "--");
+ err = gpg_keylist_build_options (gpg, secret_only, mode);
if (pattern)
{