1 /* 2 * Copyright 2009, Axel Dörfler, axeld@pinc-software.de. 3 * Copyright 2006, Ryan Leavengood, leavengood@gmail.com. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 7 8 #include <Entry.h> 9 #include <Message.h> 10 #include <Node.h> 11 #include <String.h> 12 13 14 extern "C" void 15 process_refs(entry_ref dir, BMessage* message, void* /*reserved*/) 16 { 17 entry_ref ref; 18 for (int i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) { 19 BNode node(&ref); 20 BString type; 21 22 if (node.InitCheck() == B_OK 23 && node.ReadAttrString("BEOS:TYPE", &type) == B_OK 24 && type == "text/x-email") { 25 BString previousStatus; 26 BString status("Read"); 27 28 // Only update the attribute if there is an actual change 29 if (node.ReadAttrString("MAIL:status", &previousStatus) != B_OK 30 || previousStatus != status) 31 node.WriteAttrString("MAIL:status", &status); 32 } 33 } 34 } 35 36