Mbox: add Account
authorRichard Russon <rich@flatcap.org>
Sat, 20 Oct 2018 14:33:52 +0000 (15:33 +0100)
committerRichard Russon <rich@flatcap.org>
Thu, 25 Oct 2018 20:38:43 +0000 (21:38 +0100)
mbox/mbox.c

index 1b9ea6ef3c31bde4e731a5ad11504f2edce90133..7ee8678987decb5f27d20407e494342facd208e8 100644 (file)
@@ -4,6 +4,7 @@
  *
  * @authors
  * Copyright (C) 1996-2002,2010,2013 Michael R. Elkins <me@mutt.org>
+ * Copyright (C) 2018 Richard Russon <rich@flatcap.org>
  *
  * @copyright
  * This program is free software: you can redistribute it and/or modify it under
@@ -43,6 +44,7 @@
 #include "email/lib.h"
 #include "mutt.h"
 #include "mbox.h"
+#include "account.h"
 #include "context.h"
 #include "copy.h"
 #include "globals.h"
@@ -886,6 +888,33 @@ void mbox_reset_atime(struct Mailbox *mailbox, struct stat *st)
   utime(mailbox->path, &utimebuf);
 }
 
+/**
+ * mbox_ac_find - Find a Account that matches a Mailbox path
+ */
+struct Account *mbox_ac_find(struct Account *a, const char *path)
+{
+  return NULL;
+}
+
+/**
+ * mbox_ac_add - Add a Mailbox to a Account
+ */
+int mbox_ac_add(struct Account *a, struct Mailbox *m)
+{
+  if (!a || !m)
+    return -1;
+
+  if (m->magic != MUTT_MBOX)
+    return -1;
+
+  m->account = a;
+
+  struct MailboxNode *np = mutt_mem_calloc(1, sizeof(*np));
+  np->m = m;
+  STAILQ_INSERT_TAIL(&a->mailboxes, np, entries);
+  return 0;
+}
+
 /**
  * mbox_mbox_open - Implements MxOps::mbox_open()
  */
@@ -1718,6 +1747,8 @@ static int mmdf_msg_padding_size(struct Context *ctx)
 struct MxOps mx_mbox_ops = {
   .magic            = MUTT_MBOX,
   .name             = "mbox",
+  .ac_find          = mbox_ac_find,
+  .ac_add           = mbox_ac_add,
   .mbox_open        = mbox_mbox_open,
   .mbox_open_append = mbox_mbox_open_append,
   .mbox_check       = mbox_mbox_check,
@@ -1742,6 +1773,8 @@ struct MxOps mx_mbox_ops = {
 struct MxOps mx_mmdf_ops = {
   .magic            = MUTT_MMDF,
   .name             = "mmdf",
+  .ac_find          = mbox_ac_find,
+  .ac_add           = mbox_ac_add,
   .mbox_open        = mbox_mbox_open,
   .mbox_open_append = mbox_mbox_open_append,
   .mbox_check       = mbox_mbox_check,