2305{
2307 gpgme_data_t keydata = NULL;
2308 gpgme_import_result_t impres = NULL;
2309 gpgme_import_status_t st = NULL;
2310 bool any;
2311
2313 if (!fp_in)
2314 {
2316 goto leave;
2317 }
2318
2319
2320 gpgme_error_t err = gpgme_data_new_from_stream(&keydata, fp_in);
2321 if (err != GPG_ERR_NO_ERROR)
2322 {
2323 mutt_error(
_(
"error allocating data object: %s"), gpgme_strerror(err));
2324 goto leave;
2325 }
2326
2327 err = gpgme_op_import(ctx, keydata);
2328 if (err != GPG_ERR_NO_ERROR)
2329 {
2330 mutt_error(
_(
"Error importing key: %s"), gpgme_strerror(err));
2331 goto leave;
2332 }
2333
2334
2335 impres = gpgme_op_import_result(ctx);
2336 if (!impres)
2337 {
2338 fputs("oops: no import result returned\n", stdout);
2339 goto leave;
2340 }
2341
2342 for (st = impres->imports; st; st = st->next)
2343 {
2344 if (st->result)
2345 continue;
2346 printf(
"key %s imported (",
NONULL(st->fpr));
2347
2348
2349 any = false;
2350 if (st->status & GPGME_IMPORT_SECRET)
2351 {
2352 printf("secret parts");
2353 any = true;
2354 }
2355 if ((st->status & GPGME_IMPORT_NEW))
2356 {
2357 printf("%snew key", any ? ", " : "");
2358 any = true;
2359 }
2360 if ((st->status & GPGME_IMPORT_UID))
2361 {
2362 printf("%snew uid", any ? ", " : "");
2363 any = true;
2364 }
2365 if ((st->status & GPGME_IMPORT_SIG))
2366 {
2367 printf("%snew sig", any ? ", " : "");
2368 any = true;
2369 }
2370 if ((st->status & GPGME_IMPORT_SUBKEY))
2371 {
2372 printf("%snew subkey", any ? ", " : "");
2373 any = true;
2374 }
2375 printf("%s)\n", any ? "" : "not changed");
2376
2377 }
2378
2379
2380
2381
2382
2383
2384 for (st = impres->imports; st; st = st->next)
2385 {
2386 if (st->result == 0)
2387 continue;
2388 printf(
"key %s import failed: %s\n",
NONULL(st->fpr), gpgme_strerror(st->result));
2389 }
2390 fflush(stdout);
2391
2392leave:
2393 gpgme_release(ctx);
2394 gpgme_data_release(keydata);
2396}
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)