]> granicus.if.org Git - neomutt/commitdiff
mutt_check_traditional_pgp: factor out Context
authorRichard Russon <rich@flatcap.org>
Thu, 10 Jan 2019 14:26:15 +0000 (14:26 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 8 Feb 2019 14:34:07 +0000 (14:34 +0000)
commands.c
commands.h
index.c

index 53fd3c2c9c03459297e14c89d9de4369cc6da034..084f07fd616c1b90e1e2a9842691427e38ba10d4 100644 (file)
@@ -1323,26 +1323,20 @@ static bool check_traditional_pgp(struct Email *e, int *redraw)
 
 /**
  * mutt_check_traditional_pgp - Check if a message has inline PGP content
- * @param[in]  e      Header of message to check
+ * @param[in]  el     List of Emails to check
  * @param[out] redraw Set of #REDRAW_FULL if the screen may need redrawing
  * @retval true If message contains inline PGP content
  */
-bool mutt_check_traditional_pgp(struct Email *e, int *redraw)
+bool mutt_check_traditional_pgp(struct EmailList *el, int *redraw)
 {
   bool rc = false;
-  if (e && !(e->security & PGP_TRADITIONAL_CHECKED))
-    rc = check_traditional_pgp(e, redraw);
-  else
+  struct EmailNode *en = NULL;
+  STAILQ_FOREACH(en, el, entries)
   {
-    for (int i = 0; i < Context->mailbox->msg_count; i++)
-    {
-      if (message_is_tagged(Context, i) &&
-          !(Context->mailbox->emails[i]->security & PGP_TRADITIONAL_CHECKED))
-      {
-        rc = check_traditional_pgp(Context->mailbox->emails[i], redraw) || rc;
-      }
-    }
+    if (!(en->email->security & PGP_TRADITIONAL_CHECKED))
+      rc = check_traditional_pgp(en->email, redraw) || rc;
   }
+
   return rc;
 }
 
index d6ecf22244df76ab916d8e5fc1fda19c5331181f..193b806443317d2cfa75f6cd99dbf3847bee48cc 100644 (file)
@@ -28,6 +28,7 @@
 
 struct Body;
 struct Email;
+struct EmailList;
 struct Envelope;
 struct Mailbox;
 
@@ -43,7 +44,7 @@ extern bool          PromptAfter;
 
 void ci_bounce_message(struct Mailbox *m, struct EmailList *el);
 void mutt_check_stats(void);
-bool mutt_check_traditional_pgp(struct Email *e, int *redraw);
+bool mutt_check_traditional_pgp(struct EmailList *el, int *redraw);
 void mutt_display_address(struct Envelope *env);
 int  mutt_display_message(struct Email *cur);
 int  mutt_edit_content_type(struct Email *e, struct Body *b, FILE *fp);
diff --git a/index.c b/index.c
index 4d82406d0cec134a62f31600f760fdb93e33499e..b6fea88dc9a4b2c105d8b396fcad8801bac9cf2f 100644 (file)
--- a/index.c
+++ b/index.c
@@ -2299,7 +2299,10 @@ int mutt_index_menu(void)
 
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw);
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_tagged(&el, Context, CUR_EMAIL, tag);
+          mutt_check_traditional_pgp(&el, &menu->redraw);
+          el_free(&el);
         }
         int hint =
             Context->mailbox->emails[Context->mailbox->v2r[menu->current]]->index;
@@ -3077,7 +3080,10 @@ int mutt_index_menu(void)
 
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw);
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_tagged(&el, Context, CUR_EMAIL, tag);
+          mutt_check_traditional_pgp(&el, &menu->redraw);
+          el_free(&el);
         }
         struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
         el_add_tagged(&el, Context, CUR_EMAIL, tag);
@@ -3095,7 +3101,10 @@ int mutt_index_menu(void)
         CHECK_ATTACH;
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw);
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_tagged(&el, Context, CUR_EMAIL, tag);
+          mutt_check_traditional_pgp(&el, &menu->redraw);
+          el_free(&el);
         }
         ci_send_message(SEND_FORWARD, NULL, NULL, Context, tag ? NULL : CUR_EMAIL);
         menu->redraw = REDRAW_FULL;
@@ -3112,7 +3121,10 @@ int mutt_index_menu(void)
         CHECK_ATTACH;
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw);
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_tagged(&el, Context, CUR_EMAIL, tag);
+          mutt_check_traditional_pgp(&el, &menu->redraw);
+          el_free(&el);
         }
         ci_send_message(SEND_REPLY | SEND_GROUP_REPLY, NULL, NULL, Context,
                         tag ? NULL : CUR_EMAIL);
@@ -3149,7 +3161,10 @@ int mutt_index_menu(void)
         CHECK_VISIBLE;
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw);
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_tagged(&el, Context, CUR_EMAIL, tag);
+          mutt_check_traditional_pgp(&el, &menu->redraw);
+          el_free(&el);
         }
         ci_send_message(SEND_REPLY | SEND_LIST_REPLY, NULL, NULL, Context,
                         tag ? NULL : CUR_EMAIL);
@@ -3186,7 +3201,12 @@ int mutt_index_menu(void)
         CHECK_MSGCOUNT;
         CHECK_VISIBLE;
         if (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED))
-          mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw);
+        {
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_tagged(&el, Context, CUR_EMAIL, tag);
+          mutt_check_traditional_pgp(&el, &menu->redraw);
+          el_free(&el);
+        }
 
         if (menu->menu == MENU_PAGER)
         {
@@ -3372,7 +3392,10 @@ int mutt_index_menu(void)
         CHECK_VISIBLE;
         if (PgpAutoDecode && (tag || !(CUR_EMAIL->security & PGP_TRADITIONAL_CHECKED)))
         {
-          mutt_check_traditional_pgp(tag ? NULL : CUR_EMAIL, &menu->redraw);
+          struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
+          el_add_tagged(&el, Context, CUR_EMAIL, tag);
+          mutt_check_traditional_pgp(&el, &menu->redraw);
+          el_free(&el);
         }
         ci_send_message(SEND_REPLY, NULL, NULL, Context, tag ? NULL : CUR_EMAIL);
         menu->redraw = REDRAW_FULL;