diff --git a/EDQueue.podspec b/EDQueue.podspec index 2618403..8589669 100644 --- a/EDQueue.podspec +++ b/EDQueue.podspec @@ -6,7 +6,8 @@ Pod::Spec.new do |s| s.homepage = 'https://github.com/thisandagain/queue' s.authors = {'Andrew Sliwinski' => 'andrewsliwinski@acm.org', 'Francois Lambert' => 'flambert@mirego.com'} s.source = { :git => 'https://github.com/thisandagain/queue.git', :tag => 'v0.7.1' } - s.platform = :ios, '5.0' + s.ios.platform = :ios, '5.0' + s.osx.platform = :osx, '10.8' s.source_files = 'EDQueue' s.library = 'sqlite3.0' s.requires_arc = true diff --git a/EDQueue/EDQueue.h b/EDQueue/EDQueue.h index 9d49848..711f9bb 100755 --- a/EDQueue/EDQueue.h +++ b/EDQueue/EDQueue.h @@ -6,7 +6,7 @@ // Copyright (c) 2012 Andrew Sliwinski. All rights reserved. // -#import +#import typedef NS_ENUM(NSInteger, EDQueueResult) { EDQueueResultSuccess = 0, @@ -42,6 +42,9 @@ extern NSString *const EDQueueDidDrain; - (BOOL)jobIsActiveForTask:(NSString *)task; - (NSDictionary *)nextJobForTask:(NSString *)task; +- (NSUInteger)jobCountForTask:(NSString *)task; +- (NSUInteger)totalJobCount; + @end @protocol EDQueueDelegate diff --git a/EDQueue/EDQueue.m b/EDQueue/EDQueue.m index a26f870..839b27b 100755 --- a/EDQueue/EDQueue.m +++ b/EDQueue/EDQueue.m @@ -121,6 +121,28 @@ - (NSDictionary *)nextJobForTask:(NSString *)task return nextJobForTask; } +/** + * Returns the number of jobs for task + * + * @param {NSString} Task label + * + * @return {NSUinteger} + */ +- (NSUInteger)jobCountForTask:(NSString *)task +{ + return [self.engine jobCountForTask:task]; +} + +/** + * Returns the total number of jobs + * + * @return {NSUinteger} + */ +- (NSUInteger)totalJobCount +{ + return [self.engine fetchJobCount]; +} + /** * Starts the queue. * diff --git a/EDQueue/EDQueueStorageEngine.h b/EDQueue/EDQueueStorageEngine.h index aec98f4..be3f9c6 100755 --- a/EDQueue/EDQueueStorageEngine.h +++ b/EDQueue/EDQueueStorageEngine.h @@ -19,6 +19,7 @@ - (void)removeJob:(NSNumber *)jid; - (void)removeAllJobs; - (NSUInteger)fetchJobCount; +- (NSUInteger)jobCountForTask:(id)task; - (NSDictionary *)fetchJob; - (NSDictionary *)fetchJobForTask:(id)task; diff --git a/EDQueue/EDQueueStorageEngine.m b/EDQueue/EDQueueStorageEngine.m index 9d2e907..f7b93ab 100755 --- a/EDQueue/EDQueueStorageEngine.m +++ b/EDQueue/EDQueueStorageEngine.m @@ -22,7 +22,7 @@ - (id)init self = [super init]; if (self) { // Database path - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES); + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask,YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"edqueue_0.5.0d.db"]; @@ -71,22 +71,33 @@ - (void)createJob:(id)data forTask:(id)task */ - (BOOL)jobExistsForTask:(id)task { - __block BOOL jobExists = NO; - + return [self jobCountForTask:task] > 0; +} + +/** + + * Returns the number of jobs for the specified task name. + + * + + * @param {NSString} Task name + + * + + * @return {NSUinteger} + + */ +- (NSUInteger)jobCountForTask:(id)task +{ + __block NSUInteger jobCount = 0; [self.queue inDatabase:^(FMDatabase *db) { FMResultSet *rs = [db executeQuery:@"SELECT count(id) AS count FROM queue WHERE task = ?", task]; [self _databaseHadError:[db hadError] fromDatabase:db]; while ([rs next]) { - jobExists |= ([rs intForColumn:@"count"] > 0); + jobCount = [rs intForColumn:@"count"]; } - [rs close]; }]; - return jobExists; + return jobCount; } + /** * Increments the "attempts" column for a specified job. * diff --git a/Project/macqueue.xcodeproj/project.pbxproj b/Project/macqueue.xcodeproj/project.pbxproj new file mode 100644 index 0000000..5b1cc66 --- /dev/null +++ b/Project/macqueue.xcodeproj/project.pbxproj @@ -0,0 +1,373 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 86887ABF1B0E19A900BB35FD /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887ABE1B0E19A900BB35FD /* AppDelegate.m */; }; + 86887AC11B0E19A900BB35FD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AC01B0E19A900BB35FD /* main.m */; }; + 86887AC41B0E19A900BB35FD /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AC31B0E19A900BB35FD /* ViewController.m */; }; + 86887AC61B0E19A900BB35FD /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 86887AC51B0E19A900BB35FD /* Images.xcassets */; }; + 86887AC91B0E19A900BB35FD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 86887AC71B0E19A900BB35FD /* Main.storyboard */; }; + 86887AE31B0E1EF200BB35FD /* EDQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AE01B0E1EF200BB35FD /* EDQueue.m */; }; + 86887AE41B0E1EF200BB35FD /* EDQueueStorageEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AE21B0E1EF200BB35FD /* EDQueueStorageEngine.m */; }; + 86887AF11B0E205A00BB35FD /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AE81B0E205A00BB35FD /* FMDatabase.m */; }; + 86887AF21B0E205A00BB35FD /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AEA1B0E205A00BB35FD /* FMDatabaseAdditions.m */; }; + 86887AF31B0E205A00BB35FD /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AEC1B0E205A00BB35FD /* FMDatabasePool.m */; }; + 86887AF41B0E205A00BB35FD /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AEE1B0E205A00BB35FD /* FMDatabaseQueue.m */; }; + 86887AF51B0E205A00BB35FD /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 86887AF01B0E205A00BB35FD /* FMResultSet.m */; }; + 86887AF71B0E208600BB35FD /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 86887AF61B0E208600BB35FD /* libsqlite3.0.dylib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 86887AB81B0E19A900BB35FD /* macqueue.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = macqueue.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 86887ABC1B0E19A900BB35FD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 86887ABD1B0E19A900BB35FD /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 86887ABE1B0E19A900BB35FD /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 86887AC01B0E19A900BB35FD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 86887AC21B0E19A900BB35FD /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 86887AC31B0E19A900BB35FD /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 86887AC51B0E19A900BB35FD /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 86887AC81B0E19A900BB35FD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 86887ADF1B0E1EF200BB35FD /* EDQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EDQueue.h; sourceTree = ""; }; + 86887AE01B0E1EF200BB35FD /* EDQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EDQueue.m; sourceTree = ""; }; + 86887AE11B0E1EF200BB35FD /* EDQueueStorageEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EDQueueStorageEngine.h; sourceTree = ""; }; + 86887AE21B0E1EF200BB35FD /* EDQueueStorageEngine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EDQueueStorageEngine.m; sourceTree = ""; }; + 86887AE71B0E205A00BB35FD /* FMDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabase.h; sourceTree = ""; }; + 86887AE81B0E205A00BB35FD /* FMDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabase.m; sourceTree = ""; }; + 86887AE91B0E205A00BB35FD /* FMDatabaseAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseAdditions.h; sourceTree = ""; }; + 86887AEA1B0E205A00BB35FD /* FMDatabaseAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseAdditions.m; sourceTree = ""; }; + 86887AEB1B0E205A00BB35FD /* FMDatabasePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabasePool.h; sourceTree = ""; }; + 86887AEC1B0E205A00BB35FD /* FMDatabasePool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabasePool.m; sourceTree = ""; }; + 86887AED1B0E205A00BB35FD /* FMDatabaseQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseQueue.h; sourceTree = ""; }; + 86887AEE1B0E205A00BB35FD /* FMDatabaseQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseQueue.m; sourceTree = ""; }; + 86887AEF1B0E205A00BB35FD /* FMResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMResultSet.h; sourceTree = ""; }; + 86887AF01B0E205A00BB35FD /* FMResultSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMResultSet.m; sourceTree = ""; }; + 86887AF61B0E208600BB35FD /* libsqlite3.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.0.dylib; path = usr/lib/libsqlite3.0.dylib; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 86887AB51B0E19A900BB35FD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 86887AF71B0E208600BB35FD /* libsqlite3.0.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 86887AAF1B0E19A900BB35FD = { + isa = PBXGroup; + children = ( + 86887ADE1B0E1EF200BB35FD /* EDQueue */, + 86887AE51B0E203F00BB35FD /* Lib */, + 86887ABA1B0E19A900BB35FD /* Example */, + 86887AF81B0E209300BB35FD /* Frameworks */, + 86887AB91B0E19A900BB35FD /* Products */, + ); + sourceTree = ""; + }; + 86887AB91B0E19A900BB35FD /* Products */ = { + isa = PBXGroup; + children = ( + 86887AB81B0E19A900BB35FD /* macqueue.app */, + ); + name = Products; + sourceTree = ""; + }; + 86887ABA1B0E19A900BB35FD /* Example */ = { + isa = PBXGroup; + children = ( + 86887ABD1B0E19A900BB35FD /* AppDelegate.h */, + 86887ABE1B0E19A900BB35FD /* AppDelegate.m */, + 86887AC21B0E19A900BB35FD /* ViewController.h */, + 86887AC31B0E19A900BB35FD /* ViewController.m */, + 86887AC51B0E19A900BB35FD /* Images.xcassets */, + 86887AC71B0E19A900BB35FD /* Main.storyboard */, + 86887ABB1B0E19A900BB35FD /* Supporting Files */, + ); + name = Example; + path = macqueue; + sourceTree = ""; + }; + 86887ABB1B0E19A900BB35FD /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 86887ABC1B0E19A900BB35FD /* Info.plist */, + 86887AC01B0E19A900BB35FD /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 86887ADE1B0E1EF200BB35FD /* EDQueue */ = { + isa = PBXGroup; + children = ( + 86887ADF1B0E1EF200BB35FD /* EDQueue.h */, + 86887AE01B0E1EF200BB35FD /* EDQueue.m */, + 86887AE11B0E1EF200BB35FD /* EDQueueStorageEngine.h */, + 86887AE21B0E1EF200BB35FD /* EDQueueStorageEngine.m */, + ); + name = EDQueue; + path = ../EDQueue; + sourceTree = ""; + }; + 86887AE51B0E203F00BB35FD /* Lib */ = { + isa = PBXGroup; + children = ( + 86887AE61B0E205A00BB35FD /* Fmdb */, + ); + name = Lib; + sourceTree = ""; + }; + 86887AE61B0E205A00BB35FD /* Fmdb */ = { + isa = PBXGroup; + children = ( + 86887AE71B0E205A00BB35FD /* FMDatabase.h */, + 86887AE81B0E205A00BB35FD /* FMDatabase.m */, + 86887AE91B0E205A00BB35FD /* FMDatabaseAdditions.h */, + 86887AEA1B0E205A00BB35FD /* FMDatabaseAdditions.m */, + 86887AEB1B0E205A00BB35FD /* FMDatabasePool.h */, + 86887AEC1B0E205A00BB35FD /* FMDatabasePool.m */, + 86887AED1B0E205A00BB35FD /* FMDatabaseQueue.h */, + 86887AEE1B0E205A00BB35FD /* FMDatabaseQueue.m */, + 86887AEF1B0E205A00BB35FD /* FMResultSet.h */, + 86887AF01B0E205A00BB35FD /* FMResultSet.m */, + ); + path = Fmdb; + sourceTree = ""; + }; + 86887AF81B0E209300BB35FD /* Frameworks */ = { + isa = PBXGroup; + children = ( + 86887AF61B0E208600BB35FD /* libsqlite3.0.dylib */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 86887AB71B0E19A900BB35FD /* macqueue */ = { + isa = PBXNativeTarget; + buildConfigurationList = 86887AD81B0E19A900BB35FD /* Build configuration list for PBXNativeTarget "macqueue" */; + buildPhases = ( + 86887AB41B0E19A900BB35FD /* Sources */, + 86887AB51B0E19A900BB35FD /* Frameworks */, + 86887AB61B0E19A900BB35FD /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = macqueue; + productName = macqueue; + productReference = 86887AB81B0E19A900BB35FD /* macqueue.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 86887AB01B0E19A900BB35FD /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0630; + ORGANIZATIONNAME = "Aaron Taylor"; + TargetAttributes = { + 86887AB71B0E19A900BB35FD = { + CreatedOnToolsVersion = 6.3.1; + }; + }; + }; + buildConfigurationList = 86887AB31B0E19A900BB35FD /* Build configuration list for PBXProject "macqueue" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 86887AAF1B0E19A900BB35FD; + productRefGroup = 86887AB91B0E19A900BB35FD /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 86887AB71B0E19A900BB35FD /* macqueue */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 86887AB61B0E19A900BB35FD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 86887AC61B0E19A900BB35FD /* Images.xcassets in Resources */, + 86887AC91B0E19A900BB35FD /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 86887AB41B0E19A900BB35FD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 86887AC41B0E19A900BB35FD /* ViewController.m in Sources */, + 86887AE41B0E1EF200BB35FD /* EDQueueStorageEngine.m in Sources */, + 86887AC11B0E19A900BB35FD /* main.m in Sources */, + 86887AF11B0E205A00BB35FD /* FMDatabase.m in Sources */, + 86887AF51B0E205A00BB35FD /* FMResultSet.m in Sources */, + 86887AE31B0E1EF200BB35FD /* EDQueue.m in Sources */, + 86887AF31B0E205A00BB35FD /* FMDatabasePool.m in Sources */, + 86887AF21B0E205A00BB35FD /* FMDatabaseAdditions.m in Sources */, + 86887ABF1B0E19A900BB35FD /* AppDelegate.m in Sources */, + 86887AF41B0E205A00BB35FD /* FMDatabaseQueue.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 86887AC71B0E19A900BB35FD /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 86887AC81B0E19A900BB35FD /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 86887AD61B0E19A900BB35FD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 86887AD71B0E19A900BB35FD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 86887AD91B0E19A900BB35FD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = macqueue/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 86887ADA1B0E19A900BB35FD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = macqueue/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 86887AB31B0E19A900BB35FD /* Build configuration list for PBXProject "macqueue" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 86887AD61B0E19A900BB35FD /* Debug */, + 86887AD71B0E19A900BB35FD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 86887AD81B0E19A900BB35FD /* Build configuration list for PBXNativeTarget "macqueue" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 86887AD91B0E19A900BB35FD /* Debug */, + 86887ADA1B0E19A900BB35FD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 86887AB01B0E19A900BB35FD /* Project object */; +} diff --git a/Project/macqueue.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Project/macqueue.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..92f6f46 --- /dev/null +++ b/Project/macqueue.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Project/macqueue/AppDelegate.h b/Project/macqueue/AppDelegate.h new file mode 100644 index 0000000..bfe243f --- /dev/null +++ b/Project/macqueue/AppDelegate.h @@ -0,0 +1,18 @@ +// +// AppDelegate.h +// macqueue +// +// Created by Aaron Taylor on 5/21/15. +// Copyright (c) 2015 Aaron Taylor. All rights reserved. +// + +#import +#import "EDQueue.h" + +@class ViewController; + +@interface AppDelegate : NSObject + + +@end + diff --git a/Project/macqueue/AppDelegate.m b/Project/macqueue/AppDelegate.m new file mode 100644 index 0000000..2ba649e --- /dev/null +++ b/Project/macqueue/AppDelegate.m @@ -0,0 +1,47 @@ +// +// AppDelegate.m +// macqueue +// +// Created by Aaron Taylor on 5/21/15. +// Copyright (c) 2015 Aaron Taylor. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + +- (void)queue:(EDQueue *)queue processJob:(NSDictionary *)job completion:(void (^)(EDQueueResult))block +{ + sleep(1); + + @try { + if ([[job objectForKey:@"task"] isEqualToString:@"success"]) { + block(EDQueueResultSuccess); + } else if ([[job objectForKey:@"task"] isEqualToString:@"fail"]) { + block(EDQueueResultFail); + } else { + block(EDQueueResultCritical); + } + } + @catch (NSException *exception) { + block(EDQueueResultCritical); + } +} + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + // Insert code here to initialize your application + + [[EDQueue sharedInstance] setDelegate:self]; + [[EDQueue sharedInstance] start]; +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification { + // Insert code here to tear down your application + [[EDQueue sharedInstance] stop]; +} + +@end diff --git a/Project/macqueue/Base.lproj/Main.storyboard b/Project/macqueue/Base.lproj/Main.storyboard new file mode 100644 index 0000000..bff953d --- /dev/null +++ b/Project/macqueue/Base.lproj/Main.storyboard @@ -0,0 +1,758 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + Default + + + + + + + Left to Right + + + + + + + Right to Left + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Project/macqueue/Images.xcassets/AppIcon.appiconset/Contents.json b/Project/macqueue/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/Project/macqueue/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Project/macqueue/Info.plist b/Project/macqueue/Info.plist new file mode 100644 index 0000000..b7d3baa --- /dev/null +++ b/Project/macqueue/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + com.diy.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2015 Aaron Taylor. All rights reserved. + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + + diff --git a/Project/macqueue/ViewController.h b/Project/macqueue/ViewController.h new file mode 100644 index 0000000..0b6c3e2 --- /dev/null +++ b/Project/macqueue/ViewController.h @@ -0,0 +1,21 @@ +// +// ViewController.h +// macqueue +// +// Created by Aaron Taylor on 5/21/15. +// Copyright (c) 2015 Aaron Taylor. All rights reserved. +// + +#import +#import "EDQueue.h" + +@interface ViewController : NSViewController + +@property (nonatomic, retain) IBOutlet NSTextView *activity; + +- (IBAction)addSuccess:(id)sender; +- (IBAction)addFail:(id)sender; +- (IBAction)addCritical:(id)sender; + +@end + diff --git a/Project/macqueue/ViewController.m b/Project/macqueue/ViewController.m new file mode 100644 index 0000000..863011b --- /dev/null +++ b/Project/macqueue/ViewController.m @@ -0,0 +1,72 @@ +// +// ViewController.m +// macqueue +// +// Created by Aaron Taylor on 5/21/15. +// Copyright (c) 2015 Aaron Taylor. All rights reserved. +// + +#import "ViewController.h" + +@implementation ViewController + +@synthesize activity = _activity; + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // Register notifications + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc addObserver:self selector:@selector(receivedNotification:) name:@"EDQueueJobDidSucceed" object:nil]; + [nc addObserver:self selector:@selector(receivedNotification:) name:@"EDQueueJobDidFail" object:nil]; + [nc addObserver:self selector:@selector(receivedNotification:) name:@"EDQueueDidStart" object:nil]; + [nc addObserver:self selector:@selector(receivedNotification:) name:@"EDQueueDidStop" object:nil]; + [nc addObserver:self selector:@selector(receivedNotification:) name:@"EDQueueDidDrain" object:nil]; +} + +- (void)setRepresentedObject:(id)representedObject { + [super setRepresentedObject:representedObject]; + + // Update the view, if already loaded. +} + +#pragma mark - UI events + +- (IBAction)addSuccess:(id)sender +{ + [[EDQueue sharedInstance] enqueueWithData:@{ @"nyan" : @"cat" } forTask:@"success"]; +} + +- (IBAction)addFail:(id)sender +{ + [[EDQueue sharedInstance] enqueueWithData:nil forTask:@"fail"]; +} + +- (IBAction)addCritical:(id)sender +{ + [[EDQueue sharedInstance] enqueueWithData:nil forTask:@"critical"]; +} + +#pragma mark - Notifications + +- (void)receivedNotification:(NSNotification *)notification +{ + dispatch_async(dispatch_get_main_queue(), ^{ + NSString* str = [NSString stringWithFormat:@"%@\n", notification]; + NSAttributedString* attr = [[NSAttributedString alloc] initWithString: str]; + + [[self.activity textStorage] appendAttributedString:attr]; + [self.activity scrollRangeToVisible:NSMakeRange([[self.activity string] length], 0)]; + }); +} + +#pragma mark - Dealloc + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + _activity = nil; +} + +@end diff --git a/Project/macqueue/main.m b/Project/macqueue/main.m new file mode 100644 index 0000000..17272a8 --- /dev/null +++ b/Project/macqueue/main.m @@ -0,0 +1,13 @@ +// +// main.m +// macqueue +// +// Created by Aaron Taylor on 5/21/15. +// Copyright (c) 2015 Aaron Taylor. All rights reserved. +// + +#import + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +} diff --git a/Project/queues.xcworkspace/contents.xcworkspacedata b/Project/queues.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..325d744 --- /dev/null +++ b/Project/queues.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/README.md b/README.md index 6c2d0f1..03feb2b 100644 --- a/README.md +++ b/README.md @@ -141,5 +141,8 @@ EDQueueJobDidFail ### iOS Support EDQueue is designed for iOS 5 and up. +### OSX Support +EDQueue works with at least OSX 10.8 and up. + ### ARC EDQueue is built using ARC. If you are including EDQueue in a project that **does not** use [Automatic Reference Counting (ARC)](http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html), you will need to set the `-fobjc-arc` compiler flag on all of the EDQueue source files. To do this in Xcode, go to your active target and select the "Build Phases" tab. Now select all EDQueue source files, press Enter, insert `-fobjc-arc` and then "Done" to enable ARC for EDQueue.