Permalink
Browse files

Merge pull request #108 from tipbit/is-deleted

Implement [CTCoreMessage isDeleted].
  • Loading branch information...
2 parents 6bb4d1c + 905bf5a commit dd2ad745e764962591f962f78e3e2d6b1cda55a2 @mronge mronge committed Jun 2, 2013
Showing with 15 additions and 11 deletions.
  1. +5 −0 Source/CTCoreMessage.h
  2. +10 −11 Source/CTCoreMessage.m
View
@@ -163,6 +163,11 @@
*/
- (NSDate *)senderDate;
+/**
+ Returns YES if the message is deleted.
+ */
+- (BOOL)isDeleted;
+
/**
Returns YES if the message is unread.
*/
View
@@ -408,21 +408,20 @@ - (NSDate *)senderDate {
}
- (BOOL)isUnread {
- struct mail_flags *flags = myMessage ? myMessage->msg_flags : NULL;
- if (flags != NULL) {
- BOOL flag_seen = (flags->fl_flags & MAIL_FLAG_SEEN);
- return !flag_seen;
- }
- return NO;
+ return ![self isFlagSet:MAIL_FLAG_SEEN withDefault:YES];
+}
+
+- (BOOL)isDeleted {
+ return [self isFlagSet:MAIL_FLAG_DELETED withDefault:NO];
}
- (BOOL)isStarred {
+ return [self isFlagSet:MAIL_FLAG_FLAGGED withDefault:NO];
+}
+
+- (BOOL)isFlagSet:(NSUInteger)flag withDefault:(BOOL)def {
struct mail_flags *flags = myMessage ? myMessage->msg_flags : NULL;
- if (flags != NULL) {
- BOOL flag_starred = (flags->fl_flags & MAIL_FLAG_FLAGGED);
- return flag_starred;
- }
- return NO;
+ return flags == NULL ? def : flags->fl_flags & flag;
}
- (BOOL)isNew {

0 comments on commit dd2ad74

Please sign in to comment.