]> granicus.if.org Git - neomutt/commitdiff
fill out mx_path_pretty()
authorRichard Russon <rich@flatcap.org>
Fri, 24 Aug 2018 16:09:52 +0000 (17:09 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 26 Aug 2018 21:11:03 +0000 (22:11 +0100)
compress.c
imap/imap.c
maildir/mh.c
mbox/mbox.c
mutt/path.c
mx.c
nntp/nntp.c
notmuch/mutt_notmuch.c
pop/pop.c

index 578ceafa79f6996d8c74686b08cf9dda092edd26..4798e7e8862d76a4a82d0e11e1fba4ab09e622ad 100644 (file)
@@ -930,6 +930,23 @@ int comp_path_canon(char *buf, size_t buflen, const char *folder)
   return 0;
 }
 
+/**
+ * comp_path_pretty - Implements MxOps::path_pretty
+ */
+int comp_path_pretty(char *buf, size_t buflen, const char *folder)
+{
+  if (!buf)
+    return -1;
+
+  if (mutt_path_abbr_folder(buf, buflen, folder))
+    return 0;
+
+  if (mutt_path_pretty(buf, buflen, HomeDir))
+    return 0;
+
+  return -1;
+}
+
 // clang-format off
 /**
  * struct mx_comp_ops - Mailbox callback functions for compressed mailboxes
@@ -953,6 +970,6 @@ struct MxOps mx_comp_ops = {
   .tags_commit      = NULL,
   .path_probe       = comp_path_probe,
   .path_canon       = comp_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = comp_path_pretty,
 };
 // clang-format on
index df1ebd7a512063ce4a8549dfb26526d8486fd9ec..b0490b96e6e89f7f42481d5fe7647ed677c7bc27 100644 (file)
@@ -2762,6 +2762,18 @@ int imap_path_canon(char *buf, size_t buflen, const char *folder)
   return imap_expand_path(buf, buflen);
 }
 
+/**
+ * imap_path_pretty - Implements MxOps::path_pretty
+ */
+int imap_path_pretty(char *buf, size_t buflen, const char *folder)
+{
+  if (!buf || !folder)
+    return -1;
+
+  imap_pretty_mailbox(buf, folder);
+  return 0;
+}
+
 // clang-format off
 /**
  * struct mx_imap_ops - Mailbox callback functions for IMAP mailboxes
@@ -2782,6 +2794,6 @@ struct MxOps mx_imap_ops = {
   .tags_commit      = imap_tags_commit,
   .path_probe       = imap_path_probe,
   .path_canon       = imap_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = imap_path_pretty,
 };
 // clang-format on
index db1d2a5cf7462c6a35fc58b97ce75fa9a3cd9fe4..49e88746af77bc1ebe1178ccb59917f9c57e04b2 100644 (file)
@@ -2972,6 +2972,23 @@ int maildir_path_canon(char *buf, size_t buflen, const char *folder)
   return 0;
 }
 
+/**
+ * maildir_path_pretty - Implements MxOps::path_pretty
+ */
+int maildir_path_pretty(char *buf, size_t buflen, const char *folder)
+{
+  if (!buf)
+    return -1;
+
+  if (mutt_path_abbr_folder(buf, buflen, folder))
+    return 0;
+
+  if (mutt_path_pretty(buf, buflen, HomeDir))
+    return 0;
+
+  return -1;
+}
+
 // clang-format off
 /**
  * struct mx_maildir_ops - Mailbox callback functions for Maildir mailboxes
@@ -2992,7 +3009,7 @@ struct MxOps mx_maildir_ops = {
   .tags_commit      = NULL,
   .path_probe       = maildir_path_probe,
   .path_canon       = maildir_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = maildir_path_pretty,
 };
 
 /**
@@ -3014,6 +3031,6 @@ struct MxOps mx_mh_ops = {
   .tags_commit      = NULL,
   .path_probe       = mh_path_probe,
   .path_canon       = maildir_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = maildir_path_pretty,
 };
 // clang-format on
index 98edca009774f5fd341c5f365c1f4ef04c4f92ab..d57a9c30537f48265e4c74240a0160788341c36b 100644 (file)
@@ -1397,6 +1397,23 @@ int mbox_path_canon(char *buf, size_t buflen, const char *folder)
   return 0;
 }
 
+/**
+ * mbox_path_pretty - Implements MxOps::path_pretty
+ */
+int mbox_path_pretty(char *buf, size_t buflen, const char *folder)
+{
+  if (!buf)
+    return -1;
+
+  if (mutt_path_abbr_folder(buf, buflen, folder))
+    return 0;
+
+  if (mutt_path_pretty(buf, buflen, HomeDir))
+    return 0;
+
+  return -1;
+}
+
 // clang-format off
 /**
  * struct mx_mbox_ops - Mailbox callback functions for mbox mailboxes
@@ -1417,7 +1434,7 @@ struct MxOps mx_mbox_ops = {
   .tags_commit      = NULL,
   .path_probe       = mbox_path_probe,
   .path_canon       = mbox_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = mbox_path_pretty,
 };
 
 /**
@@ -1439,6 +1456,6 @@ struct MxOps mx_mmdf_ops = {
   .tags_commit      = NULL,
   .path_probe       = mbox_path_probe,
   .path_canon       = mbox_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = mbox_path_pretty,
 };
 // clang-format on
index fac54781d2d0b3d77e32010306ec12890112b9c8..927214b61f8fc8ba58133878c95aa7c9aa4175a0 100644 (file)
@@ -350,7 +350,7 @@ char *mutt_path_concat(char *d, const char *dir, const char *fname, size_t l)
  * The slash is omitted when dir or fname is of 0 length.
  */
 char *mutt_path_concatn(char *dst, size_t dstlen, const char *dir,
-                             size_t dirlen, const char *fname, size_t fnamelen)
+                        size_t dirlen, const char *fname, size_t fnamelen)
 {
   size_t req;
   size_t offset = 0;
diff --git a/mx.c b/mx.c
index c6be439e5d3d1fe06d8365a6c081c107153c626e..ec653a23a7a4d474fbb4ce0f65118db87efea356 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1648,5 +1648,22 @@ int mx_path_canon(char *buf, size_t buflen, const char *folder)
  */
 int mx_path_pretty(char *buf, size_t buflen, const char *folder)
 {
-  return -1;
+  int magic = mx_path_probe(buf, NULL);
+  const struct MxOps *ops = mx_get_ops(magic);
+  if (!ops)
+    return -1;
+
+  if (!ops->path_canon)
+    return -1;
+
+  if (ops->path_canon(buf, buflen, folder) < 0)
+    return -1;
+
+  if (!ops->path_pretty)
+    return -1;
+
+  if (ops->path_pretty(buf, buflen, folder) < 0)
+    return -1;
+
+  return 0;
 }
index a085a68a346a8891955924f48f2c81c592b9d26e..14a7355dc52dad5069a0bccabb0e3d4d2f740ef1 100644 (file)
@@ -2668,6 +2668,15 @@ int nntp_path_canon(char *buf, size_t buflen, const char *folder)
   return 0;
 }
 
+/**
+ * nntp_path_pretty - Implements MxOps::path_pretty
+ */
+int nntp_path_pretty(char *buf, size_t buflen, const char *folder)
+{
+  /* Succeed, but don't do anything, for now */
+  return 0;
+}
+
 // clang-format off
 /**
  * struct mx_nntp_ops - Mailbox callback functions for NNTP mailboxes
@@ -2688,6 +2697,6 @@ struct MxOps mx_nntp_ops = {
   .tags_commit      = NULL,
   .path_probe       = nntp_path_probe,
   .path_canon       = nntp_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = nntp_path_pretty,
 };
 // clang-format on
index 7468becb569d7d5a672fb1b8fa1faad7e76ec0d5..f5acdd863d6cbb6001b2a5346ed4008e94c52101 100644 (file)
@@ -2803,6 +2803,15 @@ int nm_path_canon(char *buf, size_t buflen, const char *folder)
   return 0;
 }
 
+/**
+ * nm_path_pretty - Implements MxOps::path_pretty
+ */
+int nm_path_pretty(char *buf, size_t buflen, const char *folder)
+{
+  /* Succeed, but don't do anything, for now */
+  return 0;
+}
+
 // clang-format off
 /**
  * struct mx_notmuch_ops - Mailbox callback functions for Notmuch mailboxes
@@ -2823,6 +2832,6 @@ struct MxOps mx_notmuch_ops = {
   .tags_commit      = nm_tags_commit,
   .path_probe       = nm_path_probe,
   .path_canon       = nm_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = nm_path_pretty,
 };
 // clang-format on
index 16b7d0081cd144e5116d9cf5c93221cdaf8c57b1..2d303e6816002f6d6b112974a715ec53bc4cdee7 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -1099,6 +1099,15 @@ int pop_path_canon(char *buf, size_t buflen, const char *folder)
   return 0;
 }
 
+/**
+ * pop_path_pretty - Implements MxOps::path_pretty
+ */
+int pop_path_pretty(char *buf, size_t buflen, const char *folder)
+{
+  /* Succeed, but don't do anything, for now */
+  return 0;
+}
+
 // clang-format off
 /**
  * mx_pop_ops - Mailbox callback functions for POP mailboxes
@@ -1119,6 +1128,6 @@ struct MxOps mx_pop_ops = {
   .tags_commit      = NULL,
   .path_probe       = pop_path_probe,
   .path_canon       = pop_path_canon,
-  .path_pretty      = NULL,
+  .path_pretty      = pop_path_pretty,
 };
 // clang-format on