]> granicus.if.org Git - neomutt/commitdiff
probe notmuch
authorRichard Russon <rich@flatcap.org>
Sat, 25 Aug 2018 16:39:31 +0000 (17:39 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 26 Aug 2018 21:11:03 +0000 (22:11 +0100)
browser.c
mailbox.c
muttlib.c
mx.c
mx.h
notmuch/mutt_notmuch.c

index 0a33fe2afea1c9bf257827bef91b1db941951da1..9d02397ee6409e2aea56854d3bde1ad659b173b2 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -415,7 +415,7 @@ static const char *folder_format_str(char *buf, size_t buflen, size_t col, int c
       char *s = NULL;
 
 #ifdef USE_NOTMUCH
-      if (mx_is_notmuch(folder->ff->name))
+      if (nm_path_probe(folder->ff->name, NULL) == MUTT_NOTMUCH)
         s = NONULL(folder->ff->desc);
       else
 #endif
@@ -915,7 +915,7 @@ static int examine_vfolders(struct Menu *menu, struct BrowserState *state)
   struct MailboxNode *np = NULL;
   STAILQ_FOREACH(np, &AllMailboxes, entries)
   {
-    if (mx_is_notmuch(np->b->path))
+    if (nm_path_probe(np->b->path, NULL) == MUTT_NOTMUCH)
     {
       nm_nonctx_get_count(np->b->path, &np->b->msg_count, &np->b->msg_unread);
       add_folder(menu, state, np->b->path, np->b->desc, NULL, np->b, NULL);
@@ -1681,7 +1681,7 @@ void mutt_select_file(char *file, size_t filelen, int flags, char ***files, int
           mutt_str_strfcpy(file, state.entry[menu->current].name, filelen);
 #endif
 #ifdef USE_NOTMUCH
-        else if (mx_is_notmuch(state.entry[menu->current].name))
+        else if (nm_path_probe(state.entry[menu->current].name, NULL) == MUTT_NOTMUCH)
           mutt_str_strfcpy(file, state.entry[menu->current].name, filelen);
 #endif
         else
index ed39d56bbdb419b89935bcdded88f9207b10583a..569ad2623c57b3e9d8bbc4803e96ea5dd9c1acf6 100644 (file)
--- a/mailbox.c
+++ b/mailbox.c
@@ -403,7 +403,7 @@ static void mailbox_check(struct Mailbox *tmp, struct stat *contex_sb, bool chec
       tmp->magic = MUTT_NNTP;
 #endif
 #ifdef USE_NOTMUCH
-    if (mx_is_notmuch(tmp->path))
+    if (nm_path_probe(tmp->path, NULL) == MUTT_NOTMUCH)
       tmp->magic = MUTT_NOTMUCH;
     else
 #endif
@@ -623,7 +623,7 @@ int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s,
 
     mutt_extract_token(path, s, 0);
 #ifdef USE_NOTMUCH
-    if (mx_is_notmuch(path->data))
+    if (nm_path_probe(path->data, NULL) == MUTT_NOTMUCH)
       nm_normalize_uri(path->data, buf, sizeof(buf));
     else
 #endif
@@ -663,7 +663,7 @@ int mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s,
     b->newly_created = false;
     b->desc = desc;
 #ifdef USE_NOTMUCH
-    if (mx_is_notmuch(b->path))
+    if (nm_path_probe(b->path, NULL) == MUTT_NOTMUCH)
     {
       b->magic = MUTT_NOTMUCH;
       b->size = 0;
@@ -723,7 +723,7 @@ int mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s,
     else
     {
 #ifdef USE_NOTMUCH
-      if (mx_is_notmuch(path->data))
+      if (nm_path_probe(path->data, NULL) == MUTT_NOTMUCH)
       {
         nm_normalize_uri(path->data, buf, sizeof(buf));
       }
index 3cdca4f4084df4ebe335ed16f37d19713d75cfcf..6caf10a87002356245bf58770d2351eff279fa22 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -57,6 +57,9 @@
 #ifdef USE_IMAP
 #include "imap/imap.h"
 #endif
+#ifdef USE_NOTMUCH
+#include "notmuch/mutt_notmuch.h"
+#endif
 
 /* These Config Variables are only used in muttlib.c */
 struct Regex *GecosMask; ///< Config: Regex for parsing GECOS field of /etc/passwd
@@ -196,7 +199,7 @@ char *mutt_expand_path_regex(char *buf, size_t buflen, bool regex)
         else
 #endif
 #ifdef USE_NOTMUCH
-            if (mx_is_notmuch(Folder))
+            if (nm_path_probe(Folder, NULL) == MUTT_NOTMUCH)
           mutt_str_strfcpy(p, Folder, sizeof(p));
         else
 #endif
@@ -1526,7 +1529,7 @@ void mutt_get_parent_path(char *path, char *buf, size_t buflen)
   else
 #endif
 #ifdef USE_NOTMUCH
-      if (mx_is_notmuch(path))
+      if (nm_path_probe(path, NULL) == MUTT_NOTMUCH)
     mutt_str_strfcpy(buf, Folder, buflen);
   else
 #endif
diff --git a/mx.c b/mx.c
index e411b9c25abdf0d775edd14b18e51263f540fc78..5657ee5a5b0cdefd56995a2901fc8f148fa8e596 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -213,27 +213,6 @@ bool mx_is_nntp(const char *p)
 }
 #endif
 
-#ifdef USE_NOTMUCH
-/**
- * mx_is_notmuch - Is this a Notmuch mailbox
- * @param p Mailbox string to test
- * @retval true It is a Notmuch mailbox
- */
-bool mx_is_notmuch(const char *p)
-{
-  enum UrlScheme scheme;
-
-  if (!p)
-    return false;
-
-  scheme = url_check_scheme(p);
-  if (scheme == U_NOTMUCH)
-    return true;
-
-  return false;
-}
-#endif
-
 /**
  * mx_access - Wrapper for access, checks permissions on a given mailbox
  * @param path  Path of mailbox
diff --git a/mx.h b/mx.h
index 8517fd32ace9d9e5cefe82ad039c2369f0b1b9d7..1c9265aa13c6d46403e8192063a8a5d759cf8152 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -255,9 +255,6 @@ void                mx_update_tables(struct Context *ctx, bool committing);
 #ifdef USE_IMAP
 bool mx_is_imap(const char *p);
 #endif
-#ifdef USE_NOTMUCH
-bool mx_is_notmuch(const char *p);
-#endif
 #ifdef USE_NNTP
 bool mx_is_nntp(const char *p);
 #endif
index add93fe9fb6a8ae58436d60425bbc8b3fedc31c4..d2aa353475ee6393886591aedb2706457dad209c 100644 (file)
@@ -2768,8 +2768,7 @@ int nm_path_probe(const char *path, const struct stat *st)
   if (!path)
     return MUTT_UNKNOWN;
 
-  enum UrlScheme scheme = url_check_scheme(path);
-  if (scheme == U_NOTMUCH)
+  if (mutt_str_strncasecmp(path, "notmuch://", 10) == 0)
     return MUTT_NOTMUCH;
 
   return MUTT_UNKNOWN;