FREE(&a->vars);
}
+/**
+ * account_mailbox_add - Add a Mailbox to an Account
+ * @param a Account
+ * @param m Mailbox to add
+ * @retval true If Mailbox was added
+ */
+bool account_mailbox_add(struct Account *a, struct Mailbox *m)
+{
+ if (!a || !m)
+ return false;
+
+ m->account = a;
+ struct MailboxNode *np = mutt_mem_calloc(1, sizeof(*np));
+ np->mailbox = m;
+ STAILQ_INSERT_TAIL(&a->mailboxes, np, entries);
+
+ return true;
+}
+
/**
* account_mailbox_remove - Remove a Mailbox from an Account
* @param a Account
}
}
- if (STAILQ_EMPTY(&a->mailboxes))
- {
- neomutt_account_remove(NeoMutt, a);
- }
return result;
}
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_add(struct Account *a, struct Mailbox *m);
bool account_mailbox_remove(struct Account *a, struct Mailbox *m);
struct Account *account_new(void);
int account_set_value(const struct Account *a, size_t vid, intptr_t value, struct Buffer *err);
{
if (!a || !m || (m->magic != MUTT_COMPRESSED))
return -1;
-
- m->account = a;
-
- struct MailboxNode *np = mutt_mem_calloc(1, sizeof(*np));
- np->mailbox = m;
- STAILQ_INSERT_TAIL(&a->mailboxes, np, entries);
return 0;
}
if (m->mx_ops->ac_add(a, m) < 0)
return -1;
- m->account = a;
- struct MailboxNode *np = mutt_mem_calloc(1, sizeof(*np));
- np->mailbox = m;
- STAILQ_INSERT_TAIL(&a->mailboxes, np, entries);
+ account_mailbox_add(a, m);
return 0;
}
return -1;
account_mailbox_remove(m->account, m);
+ if (STAILQ_EMPTY(&m->account->mailboxes))
+ {
+ neomutt_account_remove(NeoMutt, m->account);
+ }
return 0;
}