/trunk/Source
[self truePreviewDealloc]; |
} |
|
- (void)truePreviewForwardAsAttachment:(id)inSender { |
id theMessage = [self currentDisplayedMessage]; |
|
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) { |
NSDictionary* theSettings = [theMessage truePreviewSettings]; |
|
if ([[theSettings objectForKey:@"forward"] boolValue]) { |
[self truePreviewReset]; |
[theMessage truePreviewMarkAsViewed]; |
} |
} |
|
[self truePreviewForwardAsAttachment:inSender]; |
} |
|
- (void)truePreviewForwardMessage:(id)inSender { |
id theMessage = [self currentDisplayedMessage]; |
|
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) { |
NSDictionary* theSettings = [theMessage truePreviewSettings]; |
|
if ([[theSettings objectForKey:@"forward"] boolValue]) { |
[self truePreviewReset]; |
[theMessage truePreviewMarkAsViewed]; |
} |
} |
|
[self truePreviewForwardMessage:inSender]; |
} |
|
- (void)truePreviewMarkAsRead:(id)inSender { |
[self truePreviewReset]; |
[self truePreviewMarkAsRead:inSender]; |
[self truePreviewMarkAsUnread:inSender]; |
} |
|
- (void)truePreviewMessageNoLongerDisplayedInTextView:(NSNotification*)inNotification { |
[self truePreviewMessageNoLongerDisplayedInTextView:inNotification]; |
|
// we receive notifications from all MessageContentControllers |
if ([inNotification object] != object_getIvar(self, class_getInstanceVariable([self class], "_contentController"))) { |
return; |
} |
|
[self truePreviewReset]; |
} |
|
- (void)truePreviewMessageWasDisplayedInTextView:(NSNotification*)inNotification { |
[self truePreviewMessageWasDisplayedInTextView:inNotification]; |
|
// we receive notifications from all MessageContentControllers |
if ([inNotification object] != object_getIvar(self, class_getInstanceVariable([self class], "_contentController"))) { |
return; |
} |
|
id theMessage = [[inNotification userInfo] objectForKey:@"MessageKey"]; |
|
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) { |
]; |
} |
|
if ([[theSettings objectForKey:@"scroll"] boolValue]) { |
if ( |
![self isKindOfClass:NSClassFromString(@"SingleMessageViewer")] |
&& [[theSettings objectForKey:@"scroll"] boolValue] |
) { |
// listen for bounds change notification on the message's clip view |
[[NSNotificationCenter defaultCenter] |
addObserver:self |
selector:@selector(truePreviewBoundsDidChange:) |
name:NSViewBoundsDidChangeNotification |
object:[[[[object_getIvar(self, class_getInstanceVariable([self class], "_contentController")) currentDisplay] contentView] enclosingScrollView] contentView] |
]; |
addObserver:self |
selector:@selector(truePreviewBoundsDidChange:) |
name:NSViewBoundsDidChangeNotification |
object:[[[[object_getIvar(self, class_getInstanceVariable([self class], "_contentController")) currentDisplay] contentView] enclosingScrollView] contentView] |
]; |
} |
} |
} |
|
- (void)truePreviewMessageNoLongerDisplayedInTextView:(NSNotification*)inNotification { |
[self truePreviewMessageNoLongerDisplayedInTextView:inNotification]; |
[self truePreviewReset]; |
- (void)truePreviewReplyAllMessage:(id)inSender { |
id theMessage = [self currentDisplayedMessage]; |
|
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) { |
NSDictionary* theSettings = [theMessage truePreviewSettings]; |
|
if ([[theSettings objectForKey:@"reply"] boolValue]) { |
[self truePreviewReset]; |
[theMessage truePreviewMarkAsViewed]; |
} |
} |
|
[self truePreviewReplyAllMessage:inSender]; |
} |
|
- (void)truePreviewReplyMessage:(id)inSender { |
id theMessage = [self currentDisplayedMessage]; |
|
if ([theMessage isKindOfClass:NSClassFromString(@"LibraryMessage")]) { |
NSDictionary* theSettings = [theMessage truePreviewSettings]; |
|
if ([[theSettings objectForKey:@"reply"] boolValue]) { |
[self truePreviewReset]; |
[theMessage truePreviewMarkAsViewed]; |
} |
} |
|
[self truePreviewReplyMessage:inSender]; |
} |
|
#pragma mark Accessors |
|
- (NSTimer*)truePreviewTimer { |
NSMutableDictionary* theAccount = [NSMutableDictionary dictionaryWithObjectsAndKeys: |
theDisplayName, @"displayName", |
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"delay", |
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"reply", |
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"forward", |
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"window", |
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_DEFAULT], @"scroll", |
nil |
[theAccounts |
addObserver:self |
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])] |
forKeyPath:@"reply" |
options:0 |
context:theAccounts |
]; |
[theAccounts |
addObserver:self |
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])] |
forKeyPath:@"forward" |
options:0 |
context:theAccounts |
]; |
[theAccounts |
addObserver:self |
toObjectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [theAccounts count])] |
forKeyPath:@"window" |
options:0 |
context:theAccounts |
change:(NSDictionary*)inChange |
context:(void*)inContext { |
NSMutableDictionary* theAccountDict = [NSMutableDictionary dictionary]; |
NSEnumerator* theAccountEnum = [(NSArray*)inContext objectEnumerator]; |
NSDictionary* theAccount = nil; |
|
// build the account settings dictionary to save in the user defaults |
while (theAccount = [theAccountEnum nextObject]) { |
for (NSDictionary* theAccount in (NSArray*)inContext) { |
[theAccountDict setObject:theAccount forKey:[theAccount objectForKey:@"displayName"]]; |
} |
|
- (NSMutableDictionary*)truePreviewSettings { |
NSMutableDictionary* theSettings = [NSMutableDictionary dictionaryWithObjectsAndKeys: |
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewDelay"], @"delay", |
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewReply"], @"reply", |
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewForward"], @"forward", |
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewWindow"], @"window", |
[[NSUserDefaults standardUserDefaults] objectForKey:@"TruePreviewScroll"], @"scroll", |
nil |
]; |
|
if (theAccountSettings != nil) { |
for (id theKey in [NSArray arrayWithObjects:@"delay", @"window", @"scroll", nil]) { |
for (id theKey in [NSArray arrayWithObjects:@"delay", @"reply", @"forward", @"window", @"scroll", nil]) { |
id theValue = [theAccountSettings objectForKey:theKey]; |
|
if ((theValue != nil) && ([theValue intValue] != TRUEPREVIEW_DELAY_DEFAULT)) { |
isClassMethod:NO |
]; |
[NSClassFromString(@"MessageViewer") |
truePreviewSwizzleMethod:@selector(forwardAsAttachment:) |
withMethod:@selector(truePreviewForwardAsAttachment:) |
isClassMethod:NO |
]; |
[NSClassFromString(@"MessageViewer") |
truePreviewSwizzleMethod:@selector(forwardMessage:) |
withMethod:@selector(truePreviewForwardMessage:) |
isClassMethod:NO |
]; |
[NSClassFromString(@"MessageViewer") |
truePreviewSwizzleMethod:@selector(markAsRead:) |
withMethod:@selector(truePreviewMarkAsRead:) |
isClassMethod:NO |
isClassMethod:NO |
]; |
[NSClassFromString(@"MessageViewer") |
truePreviewSwizzleMethod:@selector(messageNoLongerDisplayedInTextView:) |
withMethod:@selector(truePreviewMessageNoLongerDisplayedInTextView:) |
isClassMethod:NO |
]; |
[NSClassFromString(@"MessageViewer") |
truePreviewSwizzleMethod:@selector(messageWasDisplayedInTextView:) |
withMethod:@selector(truePreviewMessageWasDisplayedInTextView:) |
isClassMethod:NO |
]; |
[NSClassFromString(@"MessageViewer") |
truePreviewSwizzleMethod:@selector(messageNoLongerDisplayedInTextView:) |
withMethod:@selector(truePreviewMessageNoLongerDisplayedInTextView:) |
truePreviewSwizzleMethod:@selector(replyAllMessage:) |
withMethod:@selector(truePreviewReplyAllMessage:) |
isClassMethod:NO |
]; |
[NSClassFromString(@"MessageViewer") |
truePreviewSwizzleMethod:@selector(replyMessage:) |
withMethod:@selector(truePreviewReplyMessage:) |
isClassMethod:NO |
]; |
[NSClassFromString(@"NSPreferences") |
truePreviewSwizzleMethod:@selector(sharedPreferences) |
withMethod:@selector(truePreviewSharedPreferences) |
[[NSUserDefaults standardUserDefaults] |
registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: |
[NSNumber numberWithInt:TRUEPREVIEW_DELAY_IMMEDIATE], @"TruePreviewDelay", |
[NSNumber numberWithInt:NSOnState], @"TruePreviewReply", |
[NSNumber numberWithInt:NSOnState], @"TruePreviewForward", |
[NSNumber numberWithInt:NSOnState], @"TruePreviewWindow", |
[NSNumber numberWithInt:NSOffState], @"TruePreviewScroll", |
nil |
- (void)truePreviewDealloc; |
|
/*! |
* Marks the currently-displayed message as read if configured to do so when |
* forwarding. |
* @param inSender |
* Unused. |
*/ |
- (void)truePreviewForwardAsAttachment:(id)inSender; |
|
/*! |
* Marks the currently-displayed message as read if configured to do so when |
* forwarding. |
* @param inSender |
* Unused. |
*/ |
- (void)truePreviewForwardMessage:(id)inSender; |
|
/*! |
* Invalidates this instance's timer and stops observing scroll changes when a |
* message is explicitly marked as read. |
* @param inSender |
- (void)truePreviewMarkAsUnread:(id)inSender; |
|
/*! |
* Invalidates this instance's timer and stops observing scroll changes. |
* @param inNotification |
* The <code>NSNotification</code> describing the event. |
*/ |
- (void)truePreviewMessageNoLongerDisplayedInTextView:(NSNotification*)inNotification; |
|
/*! |
* Marks the displayed message as viewed, sets a timer to mark the displayed |
* message as viewed, and/or adds a notification observer to mark the message as |
* viewed when it is scrolled as appropriate. |
- (void)truePreviewMessageWasDisplayedInTextView:(id)inNotification; |
|
/*! |
* Invalidates this instance's timer and stops observing scroll changes. |
* @param inNotification |
* The <code>NSNotification</code> describing the event. |
* Marks the currently-displayed message as read if configured to do so when |
* replying. |
* @param inSender |
* Unused. |
*/ |
- (void)truePreviewMessageNoLongerDisplayedInTextView:(NSNotification*)inNotification; |
- (void)truePreviewReplyAllMessage:(id)inSender; |
|
/*! |
* Marks the currently-displayed message as read if configured to do so when |
* replying. |
* @param inSender |
* Unused. |
*/ |
- (void)truePreviewReplyMessage:(id)inSender; |
|
#pragma mark Accessors |
/*! @group Accessors */ |
|