]> granicus.if.org Git - neomutt/commitdiff
add central NeoMutt object
authorRichard Russon <rich@flatcap.org>
Mon, 20 May 2019 11:42:20 +0000 (12:42 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 3 Jun 2019 10:54:19 +0000 (11:54 +0100)
Makefile.autosetup
main.c
neomutt.c [new file with mode: 0644]
neomutt.h [new file with mode: 0644]

index ff2259ad2d0a3bfb5299cbc8fe46b58e3e340395..eb74db36402116bb099b8b317cbcb2004b068d69 100644 (file)
@@ -69,7 +69,7 @@ NEOMUTTOBJS=  account.o addrbook.o alias.o bcache.o browser.o color.o commands.o
                mutt_account.o mutt_attach.o mutt_body.o mutt_header.o \
                mutt_history.o mutt_logging.o mutt_parse.o mutt_signal.o \
                mutt_socket.o mutt_thread.o mutt_window.o mx.o myvar.o \
-               pager.o pattern.o postpone.o progress.o query.o recvattach.o \
+               neomutt.o pager.o pattern.o postpone.o progress.o query.o recvattach.o \
                recvcmd.o resize.o rfc1524.o rfc3676.o \
                score.o send.o sendlib.o sidebar.o smtp.o sort.o state.o \
                status.o system.o terminal.o version.o icommands.o
diff --git a/main.c b/main.c
index b1dce02b77e232b64bc8192963e4016dca422f52..e8db95102059f69395e575b3c6683fa0c01d5faf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -69,6 +69,7 @@
 #include "muttlib.h"
 #include "mx.h"
 #include "ncrypt/ncrypt.h"
+#include "neomutt.h"
 #include "options.h"
 #include "protos.h"
 #include "send.h"
@@ -598,6 +599,8 @@ int main(int argc, char *argv[], char *envp[])
     goto main_ok; // TEST04: neomutt -v
   }
 
+  NeoMutt = neomutt_new();
+
   Config = init_config(500);
   if (!Config)
     goto main_curses;
@@ -1262,5 +1265,6 @@ main_exit:
   mutt_free_opts();
   mutt_free_keys();
   cs_free(&Config);
+  neomutt_free(&NeoMutt);
   return rc;
 }
diff --git a/neomutt.c b/neomutt.c
new file mode 100644 (file)
index 0000000..0c34cf8
--- /dev/null
+++ b/neomutt.c
@@ -0,0 +1,58 @@
+/**
+ * @file
+ * NeoMutt container for notifications
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @page neomutt NeoMutt container for notifications
+ *
+ * NeoMutt container for notifications
+ */
+
+#include "config.h"
+#include "mutt/mutt.h"
+#include "neomutt.h"
+
+struct NeoMutt *NeoMutt; ///< Global NeoMutt object
+
+/**
+ * neomutt_new - Create the master NeoMutt object
+ * @retval ptr New NeoMutt
+ */
+struct NeoMutt *neomutt_new(void)
+{
+  struct NeoMutt *n = mutt_mem_calloc(1, sizeof(*NeoMutt));
+
+  return n;
+}
+
+/**
+ * neomutt_free - Free a NeoMutt
+ * @param[out] ptr NeoMutt to free
+ */
+void neomutt_free(struct NeoMutt **ptr)
+{
+  if (!ptr || !*ptr)
+    return;
+
+  // struct NeoMutt *n = *ptr;
+
+  FREE(ptr);
+}
diff --git a/neomutt.h b/neomutt.h
new file mode 100644 (file)
index 0000000..d8d49a9
--- /dev/null
+++ b/neomutt.h
@@ -0,0 +1,41 @@
+/**
+ * @file
+ * NeoMutt container for notifications
+ *
+ * @authors
+ * Copyright (C) 2019 Richard Russon <rich@flatcap.org>
+ *
+ * @copyright
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MUTT_NEOMUTT_H
+#define MUTT_NEOMUTT_H
+
+struct Notify;
+
+/**
+ * struct NeoMutt - Container for notifications
+ */
+struct NeoMutt
+{
+  struct Notify *notify;
+};
+
+extern struct NeoMutt *NeoMutt;
+
+struct NeoMutt *neomutt_new(void);
+void neomutt_free(struct NeoMutt **ptr);
+
+#endif /* MUTT_NEOMUTT_H */