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