2263{
2265 gpgme_data_t keydata = NULL;
2266 gpgme_import_result_t impres = NULL;
2267 gpgme_import_status_t st = NULL;
2268 bool any;
2269
2271 if (!fp_in)
2272 {
2274 goto leave;
2275 }
2276
2277
2278 gpgme_error_t err = gpgme_data_new_from_stream(&keydata, fp_in);
2279 if (err != GPG_ERR_NO_ERROR)
2280 {
2281 mutt_error(
_(
"error allocating data object: %s"), gpgme_strerror(err));
2282 goto leave;
2283 }
2284
2285 err = gpgme_op_import(ctx, keydata);
2286 if (err != 0)
2287 {
2288 mutt_error(
_(
"Error importing key: %s"), gpgme_strerror(err));
2289 goto leave;
2290 }
2291
2292
2293 impres = gpgme_op_import_result(ctx);
2294 if (!impres)
2295 {
2296 fputs("oops: no import result returned\n", stdout);
2297 goto leave;
2298 }
2299
2300 for (st = impres->imports; st; st = st->next)
2301 {
2302 if (st->result)
2303 continue;
2304 printf(
"key %s imported (",
NONULL(st->fpr));
2305
2306
2307 any = false;
2308 if (st->status & GPGME_IMPORT_SECRET)
2309 {
2310 printf("secret parts");
2311 any = true;
2312 }
2313 if ((st->status & GPGME_IMPORT_NEW))
2314 {
2315 printf("%snew key", any ? ", " : "");
2316 any = true;
2317 }
2318 if ((st->status & GPGME_IMPORT_UID))
2319 {
2320 printf("%snew uid", any ? ", " : "");
2321 any = true;
2322 }
2323 if ((st->status & GPGME_IMPORT_SIG))
2324 {
2325 printf("%snew sig", any ? ", " : "");
2326 any = true;
2327 }
2328 if ((st->status & GPGME_IMPORT_SUBKEY))
2329 {
2330 printf("%snew subkey", any ? ", " : "");
2331 any = true;
2332 }
2333 printf("%s)\n", any ? "" : "not changed");
2334
2335 }
2336
2337
2338
2339
2340
2341
2342 for (st = impres->imports; st; st = st->next)
2343 {
2344 if (st->result == 0)
2345 continue;
2346 printf(
"key %s import failed: %s\n",
NONULL(st->fpr), gpgme_strerror(st->result));
2347 }
2348 fflush(stdout);
2349
2350leave:
2351 gpgme_release(ctx);
2352 gpgme_data_release(keydata);
2354}
gpgme_ctx_t create_gpgme_context(bool for_smime)
Create a new GPGME context.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)