Changeset 3108

Show
Ignore:
Timestamp:
01/01/06 23:22:55 (3 years ago)
Author:
timothy
Message:

Mergeing the notification changes over to the branch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Additions/NSNotificationAdditions.h

    r3088 r3108  
    22- (void) postNotificationOnMainThread:(NSNotification *) notification; 
    33- (void) postNotificationOnMainThread:(NSNotification *) notification waitUntilDone:(BOOL) wait; 
    4  
    5 - (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object; 
    6 - (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo; 
    7 - (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo waitUntilDone:(BOOL) wait; 
    84@end 
    95 
  • trunk/Additions/NSNotificationAdditions.m

    r3091 r3108  
    11#import "NSNotificationAdditions.h" 
    2 #import <pthread.h> 
    32 
    43@implementation NSNotificationCenter (NSNotificationCenterAdditions) 
    54- (void) postNotificationOnMainThread:(NSNotification *) notification { 
    6         if( pthread_main_np() ) return [self postNotification:notification]; 
    75        [self postNotificationOnMainThread:notification waitUntilDone:NO]; 
    86} 
    97 
    108- (void) postNotificationOnMainThread:(NSNotification *) notification waitUntilDone:(BOOL) wait { 
    11         if( pthread_main_np() ) return [self postNotification:notification]; 
    12         [[self class] performSelectorOnMainThread:@selector( _postNotification: ) withObject:notification waitUntilDone:wait]; 
    13 
    14  
    15 + (void) _postNotification:(NSNotification *) notification { 
    16         [[self defaultCenter] postNotification:notification]; 
    17 
    18  
    19 - (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object { 
    20         if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:nil]; 
    21         [self postNotificationOnMainThreadWithName:name object:object userInfo:nil waitUntilDone:NO]; 
    22 
    23  
    24 - (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo { 
    25         if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo]; 
    26         [self postNotificationOnMainThreadWithName:name object:object userInfo:userInfo waitUntilDone:NO]; 
    27 
    28  
    29 - (void) postNotificationOnMainThreadWithName:(NSString *) name object:(id) object userInfo:(NSDictionary *) userInfo waitUntilDone:(BOOL) wait { 
    30         if( pthread_main_np() ) return [self postNotificationName:name object:object userInfo:userInfo]; 
    31  
    32         NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] init]; 
    33         [info setObject:name forKey:@"name"]; 
    34         if( object ) [info setObject:object forKey:@"object"]; 
    35         if( userInfo ) [info setObject:userInfo forKey:@"userInfo"]; 
    36  
    37         [[self class] performSelectorOnMainThread:@selector( _postNotificationName: ) withObject:info waitUntilDone:wait]; 
    38         [info release]; 
    39 
    40  
    41 + (void) _postNotificationName:(NSDictionary *) info { 
    42         NSString *name = [info objectForKey:@"name"]; 
    43         id object = [info objectForKey:@"object"]; 
    44         NSDictionary *userInfo = [info objectForKey:@"userInfo"]; 
    45  
    46         [[self defaultCenter] postNotificationName:name object:object userInfo:userInfo]; 
     9        [self performSelectorOnMainThread:@selector( postNotification: ) withObject:notification waitUntilDone:wait]; 
    4710} 
    4811@end 
     
    5013@implementation NSNotificationQueue (NSNotificationQueueAdditions) 
    5114- (void) enqueueNotificationOnMainThread:(NSNotification *) notification postingStyle:(NSPostingStyle) postingStyle { 
    52         if( pthread_main_np() ) return [self enqueueNotification:notification postingStyle:postingStyle coalesceMask:( NSNotificationCoalescingOnName | NSNotificationCoalescingOnSender ) forModes:nil]; 
    5315        [self enqueueNotificationOnMainThread:notification postingStyle:postingStyle coalesceMask:( NSNotificationCoalescingOnName | NSNotificationCoalescingOnSender ) forModes:nil]; 
    5416} 
    5517 
    5618- (void) enqueueNotificationOnMainThread:(NSNotification *) notification postingStyle:(NSPostingStyle) postingStyle coalesceMask:(unsigned) coalesceMask forModes:(NSArray *) modes { 
    57         if( pthread_main_np() ) return [self enqueueNotification:notification postingStyle:postingStyle coalesceMask:coalesceMask forModes:modes]; 
    58  
    5919        NSMutableDictionary *info = [[NSMutableDictionary allocWithZone:nil] init]; 
    6020        [info setObject:notification forKey:@"notification"]; 
     
    6323        if( modes ) [info setObject:modes forKey:@"modes"]; 
    6424 
    65         [[self class] performSelectorOnMainThread:@selector( _enqueueNotification: ) withObject:info waitUntilDone:NO]; 
     25        [self performSelectorOnMainThread:@selector( _enqueueNotification: ) withObject:info waitUntilDone:NO]; 
    6626        [info release]; 
    6727} 
    6828 
    69 + (void) _enqueueNotification:(NSDictionary *) info { 
     29- (void) _enqueueNotification:(NSDictionary *) info { 
    7030        NSNotification *notification = [info objectForKey:@"notification"]; 
    7131        NSPostingStyle postingStyle = [[info objectForKey:@"postingStyle"] unsignedIntValue]; 
     
    7333        NSArray *modes = [info objectForKey:@"modes"]; 
    7434 
    75         [[self defaultQueue] enqueueNotification:notification postingStyle:postingStyle coalesceMask:coalesceMask forModes:modes]; 
     35        [[[self class] defaultQueue] enqueueNotification:notification postingStyle:postingStyle coalesceMask:coalesceMask forModes:modes]; 
    7636} 
    7737@end