Permalink
Browse files

Added Xcode project.

  • Loading branch information...
1 parent edfc7cf commit b7742766cdfc63c44330c9436fc0b1279635be8a @rastersize committed Apr 3, 2010
Showing with 597 additions and 0 deletions.
  1. +126 −0 CDEvent.h
  2. +120 −0 CDEvent.m
  3. +298 −0 CDEvents.xcodeproj/project.pbxproj
  4. +7 −0 CDEvents_Prefix.pch
  5. +2 −0 English.lproj/InfoPlist.strings
  6. +28 −0 Info.plist
  7. +16 −0 version.plist
View
126 CDEvent.h
@@ -0,0 +1,126 @@
+/**
+ * CDEvents
+ *
+ * Copyright (c) 2010 Aron Cedercrantz
+ * http://github.com/rastersize/CDEvents/
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * @headerfile CDEvent.h CDEvents/CDEvent.h
+ * A class that wraps the data from a FSEvents event callback.
+ *
+ * Inspired by the open source project SCEvents created by Stuart Connolly
+ * http://stuconnolly.com/projects/code/
+ */
+
+#import <Foundation/Foundation.h>
+#import <CoreServices/CoreServices.h>
+
+
+/**
+ * An Objective-C wrapper for a <code>FSEvents</code>.
+ *
+ * @since 1.0.0
+ * @note Inpired by <code>SCEvent</code> class of the <code>SCEvents</code> project by Stuart Connolly.
+ * @note The class is immutable.
+ * @see FSEvents.h in CoreServices
+ */
+@interface CDEvent : NSObject <NSCoding, NSCopying> {
+@private
+ NSUInteger _identifier;
+ NSDate *_date;
+ NSURL *_URL;
+ FSEventStreamEventFlags _flags;
+}
+
+#pragma mark Properties
+/**
+ * The event identifier.
+ *
+ * The event identifier as returned by <code>FSEvents</code>.
+ *
+ * @return The event identifier.
+ */
+@property (readonly) NSUInteger identifier;
+
+/**
+ * An approximate date and time the event occured.
+ *
+ * @return The approximate date and time the event occured.
+ */
+@property (readonly) NSDate *date;
+
+/**
+ * The URL of the item which changed.
+ *
+ * @return The URL of the item which changed.
+ */
+@property (readonly) NSURL *URL;
+
+/**
+ * The flags of the event.
+ *
+ * The flags of the event as returned by <code>FSEvents</code>.
+ *
+ * @return The flags of the event.
+ * @see FSEventStreamEventFlags
+ */
+@property (readonly) FSEventStreamEventFlags flags;
+
+#pragma mark Class object creators
+
+/**
+ * Returns an <code>CDEvent</code> created with the given identifier, date, URL and flags.
+ *
+ * @param identifier The identifier of the the event.
+ * @param date The date when the event occured.
+ * @param URL The URL of the item the event concerns.
+ * @param flags The flags of the event.
+ * @return An <code>CDEvent</code> created with the given identifier, date, URL and flags.
+ * @see FSEventStreamEventFlags
+ * @see initWithIdentifier:date:URL:flags:
+ */
++ (CDEvent *)eventWithIdentifier:(NSUInteger)identifier
+ date:(NSDate *)date
+ URL:(NSURL *)URL
+ flags:(FSEventStreamEventFlags)flags;
+
+#pragma mark Init methods
+/**
+ * Returns an <code>CDEvent</code> object initialized with the given identifier, date, URL and flags.
+ *
+ * @param identifier The identifier of the the event.
+ * @param date The date when the event occured.
+ * @param URL The URL of the item the event concerns.
+ * @param flags The flags of the event.
+ * @return An <code>CDEvent</code> object initialized with the given identifier, date, URL and flags.
+ * @see FSEventStreamEventFlags
+ * @see eventWithIdentifier:date:URL:flags:
+ */
+- (id)initWithIdentifier:(NSUInteger)identifier
+ date:(NSDate *)date
+ URL:(NSURL *)URL
+ flags:(FSEventStreamEventFlags)flags;
+
+@end
View
120 CDEvent.m
@@ -0,0 +1,120 @@
+/**
+ * CDEvents
+ *
+ * Copyright (c) 2010 Aron Cedercrantz
+ * http://github.com/rastersize/CDEvents/
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#import "CDEvent.h"
+
+
+@implementation CDEvent
+
+#pragma mark Properties
+@synthesize identifier = _identifier;
+@synthesize date = _date;
+@synthesize URL = _URL;
+@synthesize flags = _flags;
+
+
+#pragma mark Class object creators
++ (CDEvent *)eventWithIdentifier:(NSUInteger)identifier
+ date:(NSDate *)date
+ URL:(NSURL *)URL
+ flags:(FSEventStreamEventFlags)flags
+{
+ return [[[CDEvent alloc] initWithIdentifier:identifier
+ date:date
+ URL:URL
+ flags:flags]
+ autorelease];
+}
+
+
+#pragma mark Init/dealloc methods
+
+- (void)dealloc
+{
+ [_date release];
+ [_URL release];
+
+ [super dealloc];
+}
+
+- (id)initWithIdentifier:(NSUInteger)identifier
+ date:(NSDate *)date
+ URL:(NSURL *)URL
+ flags:(FSEventStreamEventFlags)flags
+{
+ if ((self = [super init])) {
+ _identifier = identifier;
+ _flags = flags;
+ _date = [date retain];
+ _URL = [URL retain];
+ }
+
+ return self;
+}
+
+
+#pragma mark NSCoding methods
+
+- (void)encodeWithCoder:(NSCoder *)aCoder
+{
+ [aCoder encodeObject:[NSNumber numberWithUnsignedInteger:[self identifier]] forKey:@"identifier"];
+ [aCoder encodeObject:[NSNumber numberWithUnsignedInteger:[self flags]] forKey:@"flags"];
+ [aCoder encodeObject:[self date] forKey:@"date"];
+ [aCoder encodeObject:[self URL] forKey:@"URL"];
+}
+
+- (id)initWithCoder:(NSCoder *)aDecoder
+{
+ self = [self initWithIdentifier:[[aDecoder decodeObjectForKey:@"identifier"] unsignedIntegerValue]
+ date:[aDecoder decodeObjectForKey:@"date"]
+ URL:[aDecoder decodeObjectForKey:@"URL"]
+ flags:[[aDecoder decodeObjectForKey:@"flags"] unsignedIntegerValue]];
+
+ return self;
+}
+
+#pragma mark NSCopying methods
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ // We can do this since we are immutable.
+ return [self retain];
+}
+
+#pragma mark Public API
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"<%@: %p { identifier = %ld, URL = %@, flags = %ld, date = %@ }>",
+ [self className],
+ (unsigned long)[self identifier],
+ (unsigned long)[self flags],
+ [self date]];
+}
+
+@end
Oops, something went wrong.

0 comments on commit b774276

Please sign in to comment.