{
struct Account *a = mutt_mem_calloc(1, sizeof(struct Account));
STAILQ_INIT(&a->mailboxes);
+ a->notify = notify_new(a, NT_ACCOUNT);
return a;
}
if (a->free_adata)
a->free_adata(&a->adata);
+ notify_free(&a->notify);
account_free_config(a);
FREE(ptr);
};
TAILQ_HEAD(AccountList, Account);
+/**
+ * struct EventAccount - An Event that happened to an Account
+ */
+struct EventAccount
+{
+ struct Account *account; ///< The Account this Event relates to
+};
+
+/**
+ * enum NotifyAccount - Types of Account Event
+ */
+enum NotifyAccount
+{
+ NT_ACCOUNT_ADD = 1, ///< A new Account has been created
+ NT_ACCOUNT_REMOVE, ///< An Account is about to be destroyed
+};
+
bool account_add_config(struct Account *a, const struct ConfigSet *cs, const char *name, const char *var_names[]);
void account_free(struct Account **ptr);
void account_free_config(struct Account *a);
TAILQ_INSERT_TAIL(&n->accounts, a, entries);
notify_set_parent(a->notify, n->notify);
+ struct EventAccount ev_a = { a };
+ notify_send(n->notify, NT_ACCOUNT, NT_ACCOUNT_ADD, IP & ev_a);
return true;
}
{
if (!a || (np == a))
{
+ struct EventAccount ev_a = { np };
+ notify_send(n->notify, NT_ACCOUNT, NT_ACCOUNT_REMOVE, IP & ev_a);
TAILQ_REMOVE(&n->accounts, np, entries);
account_free(&np);
result = true;