diff --git a/baRSS.xcodeproj/project.pbxproj b/baRSS.xcodeproj/project.pbxproj index d835bde..d8a6991 100644 --- a/baRSS.xcodeproj/project.pbxproj +++ b/baRSS.xcodeproj/project.pbxproj @@ -12,12 +12,12 @@ 544FBD4721064B2F008A260C /* getFeed.py in Resources */ = {isa = PBXBuildFile; fileRef = 544FBD4621064B2F008A260C /* getFeed.py */; }; 544FBD4921064DF0008A260C /* feedparser521.py in Resources */ = {isa = PBXBuildFile; fileRef = 544FBD4821064DF0008A260C /* feedparser521.py */; }; 54ACC28121061B3B0020715F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28021061B3B0020715F /* AppDelegate.m */; }; - 54ACC28421061B3B0020715F /* baRSS.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28221061B3B0020715F /* baRSS.xcdatamodeld */; }; 54ACC28621061B3C0020715F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 54ACC28521061B3C0020715F /* Assets.xcassets */; }; 54ACC28921061B3C0020715F /* Main.xib in Resources */ = {isa = PBXBuildFile; fileRef = 54ACC28721061B3C0020715F /* Main.xib */; }; 54ACC28C21061B3C0020715F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28B21061B3C0020715F /* main.m */; }; 54ACC29521061E270020715F /* NewsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC29421061E270020715F /* NewsController.m */; }; 54ACC29821061FBA0020715F /* Preferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC29721061FBA0020715F /* Preferences.m */; }; + 54F39C2E210BE1F700AEE730 /* DBv1.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28221061B3B0020715F /* DBv1.xcdatamodeld */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -29,7 +29,7 @@ 54ACC27C21061B3B0020715F /* baRSS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = baRSS.app; sourceTree = BUILT_PRODUCTS_DIR; }; 54ACC27F21061B3B0020715F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 54ACC28021061B3B0020715F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 54ACC28321061B3B0020715F /* baRRS.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = baRRS.xcdatamodel; sourceTree = ""; }; + 54ACC28321061B3B0020715F /* DBv1.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DBv1.xcdatamodel; sourceTree = ""; }; 54ACC28521061B3C0020715F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54ACC28821061B3C0020715F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Main.xib; sourceTree = ""; }; 54ACC28A21061B3C0020715F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -104,7 +104,7 @@ 54ACC28A21061B3C0020715F /* Info.plist */, 54ACC28B21061B3C0020715F /* main.m */, 54ACC28D21061B3C0020715F /* baRSS.entitlements */, - 54ACC28221061B3B0020715F /* baRSS.xcdatamodeld */, + 54ACC28221061B3B0020715F /* DBv1.xcdatamodeld */, ); path = baRSS; sourceTree = ""; @@ -142,6 +142,9 @@ CreatedOnToolsVersion = 9.4.1; LastSwiftMigration = 0940; SystemCapabilities = { + com.apple.ApplicationGroups.Mac = { + enabled = 0; + }; com.apple.Sandbox = { enabled = 1; }; @@ -186,8 +189,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 54F39C2E210BE1F700AEE730 /* DBv1.xcdatamodeld in Sources */, 54ACC29521061E270020715F /* NewsController.m in Sources */, - 54ACC28421061B3B0020715F /* baRSS.xcdatamodeld in Sources */, 54ACC28C21061B3C0020715F /* main.m in Sources */, 54ACC28121061B3B0020715F /* AppDelegate.m in Sources */, 54ACC29821061FBA0020715F /* Preferences.m in Sources */, @@ -413,13 +416,13 @@ /* End XCConfigurationList section */ /* Begin XCVersionGroup section */ - 54ACC28221061B3B0020715F /* baRSS.xcdatamodeld */ = { + 54ACC28221061B3B0020715F /* DBv1.xcdatamodeld */ = { isa = XCVersionGroup; children = ( - 54ACC28321061B3B0020715F /* baRRS.xcdatamodel */, + 54ACC28321061B3B0020715F /* DBv1.xcdatamodel */, ); - currentVersion = 54ACC28321061B3B0020715F /* baRRS.xcdatamodel */; - path = baRSS.xcdatamodeld; + currentVersion = 54ACC28321061B3B0020715F /* DBv1.xcdatamodel */; + path = DBv1.xcdatamodeld; sourceTree = ""; versionGroupType = wrapper.xcdatamodel; }; diff --git a/baRSS/AppDelegate.m b/baRSS/AppDelegate.m index 49df037..cc427ed 100644 --- a/baRSS/AppDelegate.m +++ b/baRSS/AppDelegate.m @@ -41,9 +41,6 @@ printf("will init\n"); [PyHandler prepare]; printf("done\n"); - NSDictionary * obj = [PyHandler getFeed:@"https://feeds.feedburner.com/simpledesktops" withEtag:nil andModified:nil]; - NSLog(@"obj = %@", obj); - [self quitClicked:nil]; } @@ -60,7 +57,7 @@ // The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it. @synchronized (self) { if (_persistentContainer == nil) { - _persistentContainer = [[NSPersistentContainer alloc] initWithName:@"baRSS"]; + _persistentContainer = [[NSPersistentContainer alloc] initWithName:@"DBv1"]; [_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) { if (error != nil) { // Replace this implementation with code to handle the error appropriately. diff --git a/baRSS/Base.lproj/Main.xib b/baRSS/Base.lproj/Main.xib index f72bc40..c3e1acb 100644 --- a/baRSS/Base.lproj/Main.xib +++ b/baRSS/Base.lproj/Main.xib @@ -21,7 +21,6 @@ - @@ -447,7 +446,6 @@ - diff --git a/baRSS/baRSS.xcdatamodeld/.xccurrentversion b/baRSS/DBv1.xcdatamodeld/.xccurrentversion similarity index 86% rename from baRSS/baRSS.xcdatamodeld/.xccurrentversion rename to baRSS/DBv1.xcdatamodeld/.xccurrentversion index 2c3d4ca..a53b58b 100644 --- a/baRSS/baRSS.xcdatamodeld/.xccurrentversion +++ b/baRSS/DBv1.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - baRRS.xcdatamodel + DBv1.xcdatamodel diff --git a/baRSS/DBv1.xcdatamodeld/DBv1.xcdatamodel/contents b/baRSS/DBv1.xcdatamodeld/DBv1.xcdatamodel/contents new file mode 100644 index 0000000..f7d1ae3 --- /dev/null +++ b/baRSS/DBv1.xcdatamodeld/DBv1.xcdatamodel/contents @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/baRSS/NewsController.m b/baRSS/NewsController.m index d92229d..07120fd 100644 --- a/baRSS/NewsController.m +++ b/baRSS/NewsController.m @@ -21,33 +21,66 @@ // SOFTWARE. #import "NewsController.h" +#import "PyHandler.h" +#import "AppDelegate.h" +#import "DBv1+CoreDataModel.h" @interface NewsController () @property (weak) IBOutlet NSMenuItem *pauseItem; @property (weak) IBOutlet NSMenuItem *updateAllItem; @property (weak) IBOutlet NSMenuItem *openUnreadItem; -@property (weak) IBOutlet NSManagedObjectContext *managedObjectContext; +@property (retain) NSManagedObjectContext *managedContext; @end @implementation NewsController -- (void)viewDidLoad { - [super viewDidLoad]; - // Do view setup here. +- (void)awakeFromNib { + [super awakeFromNib]; + self.managedContext = [((AppDelegate*)[NSApp delegate]) persistentContainer].viewContext; } + - (IBAction)pauseUpdates:(NSMenuItem *)sender { NSLog(@"pause"); - NSLog(@"%@", self.managedObjectContext); + NSLog(@"%@", self.managedContext); } - (IBAction)updateAllFeeds:(NSMenuItem *)sender { NSLog(@"update all"); + NSDictionary * obj = [PyHandler getFeed:@"https://feeds.feedburner.com/simpledesktops" withEtag:nil andModified:nil]; + NSLog(@"obj = %@", obj); + // TODO: check status code + /* + Feed *a = [[Feed alloc] initWithEntity:Feed.entity insertIntoManagedObjectContext:self.managedContext]; + a.title = obj[@"feed"][@"title"]; + a.subtitle = obj[@"feed"][@"subtitle"]; + a.author = obj[@"feed"][@"author"]; + a.link = obj[@"feed"][@"link"]; + a.published = obj[@"feed"][@"published"]; + a.icon = obj[@"feed"][@"icon"]; + a.etag = obj[@"header"][@"etag"]; + a.date = obj[@"header"][@"date"]; + a.modified = obj[@"header"][@"modified"]; + for (NSDictionary *entry in obj[@"entries"]) { + FeedItem *b = [[FeedItem alloc] initWithEntity:FeedItem.entity insertIntoManagedObjectContext:self.managedContext]; + b.title = entry[@"title"]; + b.subtitle = entry[@"subtitle"]; + b.author = entry[@"author"]; + b.link = entry[@"link"]; + b.published = entry[@"published"]; + b.summary = entry[@"summary"]; + for (NSString *tag in entry[@"tags"]) { + FeedTag *c = [[FeedTag alloc] initWithEntity:FeedTag.entity insertIntoManagedObjectContext:self.managedContext]; + c.name = tag; + [b addTagsObject:c]; + } + [a addItemsObject:b]; + }*/ } - (IBAction)openAllUnread:(NSMenuItem *)sender { NSLog(@"all unread"); } - (IBAction)addFeed:(NSButton *)sender { NSLog(@"add feed"); - NSLog(@"%@", self.managedObjectContext); + NSLog(@"%@", self.managedContext); } - (IBAction)removeFeed:(NSButton *)sender { NSLog(@"del feed"); diff --git a/baRSS/Preferences.m b/baRSS/Preferences.m index df8f012..1efcb23 100644 --- a/baRSS/Preferences.m +++ b/baRSS/Preferences.m @@ -31,11 +31,12 @@ @end @implementation Preferences - -- (void)windowDidLoad { - [super windowDidLoad]; - NSLog(@"%@", @"hi"); - // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. +- (void)awakeFromNib { + [super awakeFromNib]; + if (self.window.contentView.subviews.count == 0) { + self.window.contentView = self.viewGeneral; + self.toolbar.selectedItemIdentifier = self.toolbar.items.firstObject.itemIdentifier; + } } - (IBAction)clickGeneral:(NSToolbarItem *)sender { diff --git a/baRSS/baRSS.xcdatamodeld/baRRS.xcdatamodel/contents b/baRSS/baRSS.xcdatamodeld/baRRS.xcdatamodel/contents deleted file mode 100644 index ad82c3b..0000000 --- a/baRSS/baRSS.xcdatamodeld/baRRS.xcdatamodel/contents +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file