]> granicus.if.org Git - neomutt/commitdiff
rename account_remove_mailbox()
authorRichard Russon <rich@flatcap.org>
Wed, 3 Jul 2019 12:58:35 +0000 (13:58 +0100)
committerRichard Russon <rich@flatcap.org>
Fri, 5 Jul 2019 11:16:25 +0000 (12:16 +0100)
account.c
account.h
mx.c

index b8808d345ba3f6518b9dd430d55f7cbc4d5e0d41..96a013efb7795dca3085b725c58bdf2b7b732d47 100644 (file)
--- a/account.c
+++ b/account.c
@@ -119,38 +119,23 @@ void account_free_config(struct Account *a)
 }
 
 /**
- * account_free - Free an Account
- * @param[out] ptr Account to free
- */
-void account_free(struct Account **ptr)
-{
-  if (!ptr || !*ptr)
-    return;
-
-  struct Account *a = *ptr;
-  if (!TAILQ_EMPTY(&AllAccounts))
-    TAILQ_REMOVE(&AllAccounts, a, entries);
-  if (a->free_adata)
-    a->free_adata(&a->adata);
-
-  account_free_config(a);
-
-  FREE(ptr);
-}
-
-/**
- * account_remove_mailbox - Remove a Mailbox from an Account
+ * account_mailbox_remove - Remove a Mailbox from an Account
  * @param a Account
  * @param m Mailbox to remove
  */
-void account_remove_mailbox(struct Account *a, struct Mailbox *m)
+bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
 {
+  if (!a)
+    return false;
+
+  bool result = false;
   struct MailboxNode *np = NULL;
   STAILQ_FOREACH(np, &a->mailboxes, entries)
   {
     if (np->mailbox == m)
     {
       STAILQ_REMOVE(&a->mailboxes, np, MailboxNode, entries);
+      result = true;
       break;
     }
   }
@@ -159,6 +144,27 @@ void account_remove_mailbox(struct Account *a, struct Mailbox *m)
   {
     account_free(&a);
   }
+  return result;
+}
+
+/**
+ * account_free - Free an Account
+ * @param[out] ptr Account to free
+ */
+void account_free(struct Account **ptr)
+{
+  if (!ptr || !*ptr)
+    return;
+
+  struct Account *a = *ptr;
+  if (!TAILQ_EMPTY(&AllAccounts))
+    TAILQ_REMOVE(&AllAccounts, a, entries);
+  if (a->free_adata)
+    a->free_adata(&a->adata);
+
+  account_free_config(a);
+
+  FREE(ptr);
 }
 
 /**
index 2be4f49cc1e9fb38caba83d6803e40b190d151cf..2f21b2d436e249994e69d764ceffa6e65de76e65 100644 (file)
--- a/account.h
+++ b/account.h
@@ -24,7 +24,8 @@
 #ifndef MUTT_ACCOUNT_H
 #define MUTT_ACCOUNT_H
 
-#include "mutt/queue.h"
+#include <stdbool.h>
+#include "mutt/mutt.h"
 #include "config/lib.h"
 #include "mailbox.h"
 
@@ -55,8 +56,8 @@ bool            account_add_config(struct Account *a, const struct ConfigSet *cs
 void            account_free(struct Account **ptr);
 void            account_free_config(struct Account *a);
 int             account_get_value(const struct Account *a, size_t vid, struct Buffer *result);
+bool            account_mailbox_remove(struct Account *a, struct Mailbox *m);
 struct Account *account_new(void);
-void            account_remove_mailbox(struct Account *a, struct Mailbox *m);
 int             account_set_value(const struct Account *a, size_t vid, intptr_t value, struct Buffer *err);
 
 #endif /* MUTT_ACCOUNT_H */
diff --git a/mx.c b/mx.c
index 5faa4e5eec94a946e869d24cb8dd0b89084547fc..0d4f7796a19a7369e7b9f00c968054db99dbe279 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1587,7 +1587,7 @@ int mx_ac_remove(struct Mailbox *m)
   if (!m || !m->account)
     return -1;
 
-  account_remove_mailbox(m->account, m);
+  account_mailbox_remove(m->account, m);
   return 0;
 }