mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-12 17:11:12 +00:00
fix whitespace/indentatrion issues
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37647 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
28cac03e05
commit
5a5946dfce
2 changed files with 108 additions and 98 deletions
|
@ -44,11 +44,11 @@ extern "C" {
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
NSUserNotificationActivationTypeNone = 0,
|
NSUserNotificationActivationTypeNone = 0,
|
||||||
NSUserNotificationActivationTypeContentsClicked = 1,
|
NSUserNotificationActivationTypeContentsClicked = 1,
|
||||||
NSUserNotificationActivationTypeActionButtonClicked = 2
|
NSUserNotificationActivationTypeActionButtonClicked = 2
|
||||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_9,GS_API_LATEST)
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_9,GS_API_LATEST)
|
||||||
,NSUserNotificationActivationTypeReplied = 3
|
,NSUserNotificationActivationTypeReplied = 3
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
typedef NSInteger NSUserNotificationActivationType;
|
typedef NSInteger NSUserNotificationActivationType;
|
||||||
|
@ -57,8 +57,8 @@ typedef NSInteger NSUserNotificationActivationType;
|
||||||
@interface NSUserNotification : NSObject <NSCopying>
|
@interface NSUserNotification : NSObject <NSCopying>
|
||||||
{
|
{
|
||||||
#if GS_EXPOSE(NSUserNotification)
|
#if GS_EXPOSE(NSUserNotification)
|
||||||
@public
|
@public
|
||||||
id _uniqueId;
|
id _uniqueId;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,8 @@ GS_EXPORT NSString * const NSUserNotificationDefaultSoundName;
|
||||||
@interface NSUserNotificationCenter : NSObject
|
@interface NSUserNotificationCenter : NSObject
|
||||||
{
|
{
|
||||||
#if GS_EXPOSE(NSUserNotificationCenter)
|
#if GS_EXPOSE(NSUserNotificationCenter)
|
||||||
NSMutableArray *_scheduledNotifications;
|
NSMutableArray *_scheduledNotifications;
|
||||||
NSMutableArray *_deliveredNotifications;
|
NSMutableArray *_deliveredNotifications;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,9 +126,12 @@ GS_EXPORT NSString * const NSUserNotificationDefaultSoundName;
|
||||||
@interface NSObject (NSUserNotificationCenterDelegateMethods)
|
@interface NSObject (NSUserNotificationCenterDelegateMethods)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
- (void) userNotificationCenter: (NSUserNotificationCenter *)center didDeliverNotification: (NSUserNotification *)notification;
|
- (void) userNotificationCenter: (NSUserNotificationCenter *)center
|
||||||
- (void) userNotificationCenter: (NSUserNotificationCenter *)center didActivateNotification: (NSUserNotification *)notification;
|
didDeliverNotification: (NSUserNotification *)notification;
|
||||||
- (BOOL) userNotificationCenter: (NSUserNotificationCenter *)center shouldPresentNotification: (NSUserNotification *)notification;
|
- (void) userNotificationCenter: (NSUserNotificationCenter *)center
|
||||||
|
didActivateNotification: (NSUserNotification *)notification;
|
||||||
|
- (BOOL) userNotificationCenter: (NSUserNotificationCenter *)center
|
||||||
|
shouldPresentNotification: (NSUserNotification *)notification;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -46,33 +46,32 @@
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (nil != (self = [super init]))
|
||||||
if (self)
|
{
|
||||||
{
|
self.hasActionButton = YES;
|
||||||
self.hasActionButton = YES;
|
}
|
||||||
}
|
return self;
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
RELEASE(_uniqueId);
|
RELEASE(_uniqueId);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) copyWithZone: (NSZone *)zone
|
- (id) copyWithZone: (NSZone *)zone
|
||||||
{
|
{
|
||||||
return NSCopyObject(self, 0, zone);
|
return NSCopyObject(self, 0, zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)description
|
- (NSString *)description
|
||||||
{
|
{
|
||||||
return [NSString stringWithFormat:@"<%s:%p> { title: \"%@\" "
|
return [NSString stringWithFormat:@"<%s:%p> { title: \"%@\" "
|
||||||
"informativeText: \"%@\" "
|
"informativeText: \"%@\" "
|
||||||
"actionButtonTitle: \"%@\" }",
|
"actionButtonTitle: \"%@\" }",
|
||||||
object_getClassName(self), self,
|
object_getClassName(self), self,
|
||||||
self.title, self.informativeText,
|
self.title, self.informativeText,
|
||||||
self.actionButtonTitle];
|
self.actionButtonTitle];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -93,106 +92,110 @@ static NSUserNotificationCenter *defaultUserNotificationCenter = nil;
|
||||||
|
|
||||||
+ (Class) defaultUserNotificationCenterClass
|
+ (Class) defaultUserNotificationCenterClass
|
||||||
{
|
{
|
||||||
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
|
NSBundle *bundle = [NSBundle bundleForClass: [self class]];
|
||||||
NSString *bundlePath = [bundle pathForResource: @"NSUserNotification"
|
NSString *bundlePath = [bundle pathForResource: @"NSUserNotification"
|
||||||
ofType: @"bundle"
|
ofType: @"bundle"
|
||||||
inDirectory: nil];
|
inDirectory: nil];
|
||||||
if (bundlePath)
|
if (bundlePath)
|
||||||
{
|
{
|
||||||
bundle = [NSBundle bundleWithPath: bundlePath];
|
bundle = [NSBundle bundleWithPath: bundlePath];
|
||||||
if (bundle)
|
if (bundle)
|
||||||
return [bundle principalClass];
|
{
|
||||||
}
|
return [bundle principalClass];
|
||||||
return self;
|
}
|
||||||
|
}
|
||||||
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) atExit
|
+ (void) atExit
|
||||||
{
|
{
|
||||||
DESTROY(defaultUserNotificationCenter);
|
DESTROY(defaultUserNotificationCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if ([NSUserNotificationCenter class] == self)
|
if ([NSUserNotificationCenter class] == self)
|
||||||
{
|
{
|
||||||
Class uncClass = [self defaultUserNotificationCenterClass];
|
Class uncClass = [self defaultUserNotificationCenterClass];
|
||||||
defaultUserNotificationCenter = [[uncClass alloc] init];
|
defaultUserNotificationCenter = [[uncClass alloc] init];
|
||||||
[self registerAtExit];
|
[self registerAtExit];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) setDefaultUserNotificationCenter: (NSUserNotificationCenter *)unc
|
+ (void) setDefaultUserNotificationCenter: (NSUserNotificationCenter *)unc
|
||||||
{
|
{
|
||||||
ASSIGN(defaultUserNotificationCenter, unc);
|
ASSIGN(defaultUserNotificationCenter, unc);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSUserNotificationCenter *) defaultUserNotificationCenter
|
+ (NSUserNotificationCenter *) defaultUserNotificationCenter
|
||||||
{
|
{
|
||||||
return defaultUserNotificationCenter;
|
return defaultUserNotificationCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
self = [super init];
|
if (nil != (self = self = [super init]))
|
||||||
if (self)
|
{
|
||||||
{
|
_scheduledNotifications = [[NSMutableArray alloc] init];
|
||||||
_scheduledNotifications = [[NSMutableArray alloc] init];
|
_deliveredNotifications = [[NSMutableArray alloc] init];
|
||||||
_deliveredNotifications = [[NSMutableArray alloc] init];
|
}
|
||||||
}
|
return self;
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[NSObject cancelPreviousPerformRequestsWithTarget: self];
|
[NSObject cancelPreviousPerformRequestsWithTarget: self];
|
||||||
RELEASE(_scheduledNotifications);
|
RELEASE(_scheduledNotifications);
|
||||||
[self removeAllDeliveredNotifications];
|
[self removeAllDeliveredNotifications];
|
||||||
RELEASE(_deliveredNotifications);
|
RELEASE(_deliveredNotifications);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) scheduleNotification: (NSUserNotification *)un
|
- (void) scheduleNotification: (NSUserNotification *)un
|
||||||
{
|
{
|
||||||
if (!un.deliveryDate)
|
if (!un.deliveryDate)
|
||||||
{
|
{
|
||||||
[self deliverNotification: un];
|
[self deliverNotification: un];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
[_scheduledNotifications addObject: un];
|
[_scheduledNotifications addObject: un];
|
||||||
NSTimeInterval delay = [un.deliveryDate timeIntervalSinceNow];
|
NSTimeInterval delay = [un.deliveryDate timeIntervalSinceNow];
|
||||||
[self performSelector: @selector(deliverNotification:)
|
[self performSelector: @selector(deliverNotification:)
|
||||||
withObject: un
|
withObject: un
|
||||||
afterDelay: delay];
|
afterDelay: delay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeScheduledNotification: (NSUserNotification *)un
|
- (void) removeScheduledNotification: (NSUserNotification *)un
|
||||||
{
|
{
|
||||||
[NSObject cancelPreviousPerformRequestsWithTarget: self
|
[NSObject cancelPreviousPerformRequestsWithTarget: self
|
||||||
selector: @selector(deliverNotification:)
|
selector: @selector(deliverNotification:)
|
||||||
object: un];
|
object: un];
|
||||||
[_scheduledNotifications removeObject: un];
|
[_scheduledNotifications removeObject: un];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _deliverNotification: (NSUserNotification *)un
|
- (void) _deliverNotification: (NSUserNotification *)un
|
||||||
{
|
{
|
||||||
NSLog(@"%s -- needs implementation", __PRETTY_FUNCTION__);
|
NSLog(@"%s -- needs implementation", __PRETTY_FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) deliverNotification: (NSUserNotification *)un
|
- (void) deliverNotification: (NSUserNotification *)un
|
||||||
{
|
{
|
||||||
[self removeScheduledNotification: un];
|
[self removeScheduledNotification: un];
|
||||||
[self _deliverNotification: un];
|
[self _deliverNotification: un];
|
||||||
|
|
||||||
NSDate *actualDeliveryDate = un.deliveryDate;
|
NSDate *actualDeliveryDate = un.deliveryDate;
|
||||||
if (!actualDeliveryDate)
|
if (!actualDeliveryDate)
|
||||||
actualDeliveryDate = [NSDate date];
|
actualDeliveryDate = [NSDate date];
|
||||||
un.actualDeliveryDate = actualDeliveryDate;
|
un.actualDeliveryDate = actualDeliveryDate;
|
||||||
[_deliveredNotifications addObject: un];
|
[_deliveredNotifications addObject: un];
|
||||||
un.presented = YES;
|
un.presented = YES;
|
||||||
|
|
||||||
if (self.delegate && [self.delegate respondsToSelector: @selector(userNotificationCenter:didDeliverNotification:)])
|
if (self.delegate && [self.delegate respondsToSelector:
|
||||||
[self.delegate userNotificationCenter: self didDeliverNotification: un];
|
@selector(userNotificationCenter:didDeliverNotification:)])
|
||||||
|
{
|
||||||
|
[self.delegate userNotificationCenter: self didDeliverNotification: un];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _removeDeliveredNotification: (NSUserNotification *)un
|
- (void) _removeDeliveredNotification: (NSUserNotification *)un
|
||||||
|
@ -201,31 +204,35 @@ static NSUserNotificationCenter *defaultUserNotificationCenter = nil;
|
||||||
|
|
||||||
- (void) removeDeliveredNotification: (NSUserNotification *)un
|
- (void) removeDeliveredNotification: (NSUserNotification *)un
|
||||||
{
|
{
|
||||||
[self _removeDeliveredNotification: un];
|
[self _removeDeliveredNotification: un];
|
||||||
[_deliveredNotifications removeObject: un];
|
[_deliveredNotifications removeObject: un];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeAllDeliveredNotifications
|
- (void) removeAllDeliveredNotifications
|
||||||
{
|
{
|
||||||
NSUInteger i, count = [_deliveredNotifications count];
|
NSUInteger i, count = [_deliveredNotifications count];
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
for (i = 0; i < count; i++)
|
||||||
NSUserNotification *un = [_deliveredNotifications objectAtIndex: i];
|
{
|
||||||
[self _removeDeliveredNotification:un];
|
NSUserNotification *un = [_deliveredNotifications objectAtIndex: i];
|
||||||
}
|
[self _removeDeliveredNotification:un];
|
||||||
[_deliveredNotifications removeAllObjects];
|
}
|
||||||
|
[_deliveredNotifications removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSUserNotification *) deliveredNotificationWithUniqueId: (id)uniqueId
|
- (NSUserNotification *) deliveredNotificationWithUniqueId: (id)uniqueId
|
||||||
{
|
{
|
||||||
NSUInteger i, count = [_deliveredNotifications count];
|
NSUInteger i, count = [_deliveredNotifications count];
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
for (i = 0; i < count; i++)
|
||||||
NSUserNotification *un = [_deliveredNotifications objectAtIndex: i];
|
{
|
||||||
if ([un->_uniqueId isEqual: uniqueId])
|
NSUserNotification *un = [_deliveredNotifications objectAtIndex: i];
|
||||||
return un;
|
if ([un->_uniqueId isEqual: uniqueId])
|
||||||
}
|
{
|
||||||
return nil;
|
return un;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue