Ticket #7458: markasdiff.txt

File markasdiff.txt, 3.7 KB (added by jalopeura, 13 years ago)

Patch

Line 
1Index: haiku/src/add-ons/tracker/mark_as/MarkAs.cpp
2===================================================================
3--- haiku/src/add-ons/tracker/mark_as/MarkAs.cpp (revision 41271)
4+++ haiku/src/add-ons/tracker/mark_as/MarkAs.cpp (working copy)
5@@ -16,6 +16,8 @@
6 #include <Path.h>
7 #include <PopUpMenu.h>
8 #include <String.h>
9+//#include <E-mail.h>
10+#include <mail_util.h>
11
12
13 static BPoint
14@@ -94,7 +96,29 @@
15 && node.ReadAttrString("BEOS:TYPE", &type) == B_OK
16 && type == "text/x-email") {
17 BString previousStatus;
18+ read_flags previousRead;
19+
20+ // Update the MAIL:read flag
21+ if (status == "New") {
22+ if (read_read_attr(node, previousRead) != B_OK ||
23+ previousRead != B_UNREAD)
24+ write_read_attr(node, B_UNREAD);
25+ }
26+ else if (status == "Read") {
27+ // if we're marking it via the add-on, we haven't really read it
28+ // so use B_SEEN instead of B_READ
29+ // Check both B_SEEN and B_READ
30+ // (so we don't overwrite B_READ with B_SEEN)
31+ if (read_read_attr(node, previousRead) != B_OK ||
32+ (previousRead != B_SEEN && previousRead != B_READ))
33+ write_read_attr(node, B_SEEN);
34+ }
35+ // ignore "Replied"; no matching MAIL:read status
36
37+ // We want to keep the previous behavior of updating the status
38+ // string, but write_read_attr will only change the status string
39+ // if it's one of "New", "Seen", or "Read" (and not, for example,
40+ // "Replied"), so we change the status string here
41 // Only update the attribute if there is an actual change
42 if (node.ReadAttrString("MAIL:status", &previousStatus) != B_OK
43 || previousStatus != status)
44Index: haiku/src/add-ons/tracker/mark_as/Jamfile
45===================================================================
46--- haiku/src/add-ons/tracker/mark_as/Jamfile (revision 41271)
47+++ haiku/src/add-ons/tracker/mark_as/Jamfile (working copy)
48@@ -2,15 +2,17 @@
49
50 SetSubDirSupportedPlatformsBeOSCompatible ;
51
52+UsePrivateHeaders mail ;
53+
54 AddResources Mark\ as… : MarkAs.rdef ;
55 AddResources Mark\ as\ Read-R : MarkAsRead.rdef ;
56
57 Addon Mark\ as… :
58 MarkAs.cpp
59- : be tracker $(TARGET_LIBSUPC++)
60+ : be tracker $(TARGET_LIBSUPC++) libmail.so
61 ;
62
63 Addon Mark\ as\ Read-R :
64 MarkAsRead.cpp
65- : be tracker $(TARGET_LIBSUPC++)
66+ : be tracker $(TARGET_LIBSUPC++) libmail.so
67 ;
68Index: haiku/src/add-ons/tracker/mark_as/MarkAsRead.cpp
69===================================================================
70--- haiku/src/add-ons/tracker/mark_as/MarkAsRead.cpp (revision 41271)
71+++ haiku/src/add-ons/tracker/mark_as/MarkAsRead.cpp (working copy)
72@@ -9,8 +9,9 @@
73 #include <Message.h>
74 #include <Node.h>
75 #include <String.h>
76+//#include <E-mail.h>
77+#include <mail_util.h>
78
79-
80 extern "C" void
81 process_refs(entry_ref dir, BMessage* message, void* /*reserved*/)
82 {
83@@ -24,7 +25,22 @@
84 && type == "text/x-email") {
85 BString previousStatus;
86 BString status("Read");
87+ read_flags previousRead;
88+ // if we're marking it via the add-on, we haven't really read it
89+ // so use B_SEEN instead of B_READ
90+ read_flags read = B_SEEN;
91+
92+ // Update the MAIL:read status to match
93+ // Check both B_SEEN and B_READ
94+ // (so we don't overwrite B_READ with B_SEEN)
95+ if (read_read_attr(node, previousRead) != B_OK ||
96+ (previousRead != B_SEEN && previousRead != B_READ))
97+ write_read_attr(node, read);
98
99+ // We want to keep the previous behavior of updating the status
100+ // string, but write_read_attr will only change the status string
101+ // if it's one of "New", "Seen", or "Read" (and not, for example,
102+ // "Replied"), so we change the status string here
103 // Only update the attribute if there is an actual change
104 if (node.ReadAttrString("MAIL:status", &previousStatus) != B_OK
105 || previousStatus != status)