Permalink
Browse files

Merge branch 'develop' into warningsRemoval

  • Loading branch information...
mgmart committed Jul 15, 2017
2 parents eca10cd + 046af86 commit d658acba4cad817c366176ef0c87c16bc8c3a67b
Showing with 481 additions and 34 deletions.
  1. +17 −2 .travis.yml
  2. +2 −1 Classes/Capture/NoteListController.m
  3. +4 −2 Classes/Outline/OutlineViewController.m
  4. +1 −0 Classes/Outline/TagEditController.h
  5. +1 −1 Classes/Parsing/OrgFileParser.m
  6. +22 −0 Classes/PersistenceStack.swift
  7. +3 −2 Classes/Search/SearchController.m
  8. +5 −0 Classes/Settings/SettingsController.swift
  9. +2 −2 Classes/Sync/SyncManager.m
  10. +3 −2 Classes/Sync/WebDavTransferManager.swift
  11. +23 −22 Classes/Utilities/DataUtils.m
  12. +8 −0 MobileOrg.xcodeproj/project.pbxproj
  13. +146 −0 MobileOrg.xcodeproj/xcshareddata/xcschemes/All Tests.xcscheme
  14. +5 −0 MobileOrg.xcodeproj/xcshareddata/xcschemes/MobileOrg.xcscheme
  15. +1 −0 MobileOrgTests/MobileOrgTests-Bridging-Header.h
  16. +26 −0 MobileOrgTests/Resources/WebDavTests/certs/web.crt
  17. +32 −0 MobileOrgTests/Resources/WebDavTests/certs/web.key
  18. BIN MobileOrgTests/Resources/WebDavTests/content/MobileOrgTestingSample.org
  19. BIN MobileOrgTests/Resources/WebDavTests/content/agendas.org
  20. +7 −0 MobileOrgTests/Resources/WebDavTests/content/checksums.dat
  21. +1 −0 MobileOrgTests/Resources/WebDavTests/content/headingskip.org
  22. BIN MobileOrgTests/Resources/WebDavTests/content/index.org
  23. +1 −0 MobileOrgTests/Resources/WebDavTests/content/mobileorg.org
  24. BIN MobileOrgTests/Resources/WebDavTests/content/sample.org
  25. BIN MobileOrgTests/Resources/WebDavTests/content/second.org
  26. +1 −0 MobileOrgTests/Resources/WebDavTests/htpasswd
  27. +145 −0 MobileOrgTests/WebDavTests.swift
  28. +8 −0 README.org
  29. +13 −0 Scripts/WebDAV-Server-Start.sh
  30. +4 −0 Scripts/WebDAV-Server-Stop.sh
View
@@ -1,11 +1,26 @@
# Travis
# sudo: required
language: objective-c
osx_image: xcode8.2
# addons:
# hosts:
# - mobileOrgWebDav.schnuddelhuddel.de
# dist: trusty
# services:
# - docker
# before_install:
# - docker pull phylor/webdav-ssl
# - docker run -v $PWD/htpasswd:/htpasswd -v $PWD/certs:/certs -v $PWD/content:/var/www -h mobileOrgWebDav.schnuddelhuddel.de -p 32773:443 phylor/webdav-ssl
osx_image: xcode8.3
# xcode_project: MobileOrg.xcodeproj
# xcode_scheme: MobileOrg
xcode_scheme: MobileOrg
script:
xcodebuild test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -workspace MobileOrg.xcworkspace -scheme MobileOrg -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3'|xcpretty
@@ -26,6 +26,7 @@
#import "Node.h"
#import "DataUtils.h"
#import "GlobalUtils.h"
#import "MobileOrg-Swift.h"
@implementation NoteListController
@@ -67,7 +68,7 @@ - (void)addNote {
[self stopEditing];
Note *newNote = (Note*)[NSEntityDescription insertNewObjectForEntityForName:@"Note" inManagedObjectContext:[AppInstance() managedObjectContext]];
Note *newNote = (Note*)[NSEntityDescription insertNewObjectForEntityForName:@"Note" inManagedObjectContext:PersistenceStack.shared.moc];
[newNote setCreatedAt:[NSDate date]];
[newNote setNoteId:UUID()];
[newNote setLocallyModified:[NSNumber numberWithBool:true]];
@@ -185,8 +185,10 @@ - (void)updateBadge {
self.navigationController.tabBarItem.badgeValue = [[NSNumber numberWithInt:numLocalEdits] stringValue];
self.navigationItem.leftBarButtonItem.enabled = YES;
} else {
self.navigationController.tabBarItem.badgeValue = nil;
self.navigationItem.leftBarButtonItem.enabled = NO;
dispatch_async(dispatch_get_main_queue(), ^{
self.navigationController.tabBarItem.badgeValue = nil;
self.navigationItem.leftBarButtonItem.enabled = NO;
});
}
UpdateAppBadge();
@@ -40,5 +40,6 @@
@property (nonatomic, copy) NSString *recentTagString;
- (id)initWithNode:(Node*)aNode;
- (void)commitNewTag;
@end
@@ -45,7 +45,7 @@ - (void)parse:(NSManagedObjectContext *)moc {
NSMutableArray *nodeStack;
NSManagedObjectContext *managedObjectContext;
managedObjectContext = moc; // [AppInstance() managedObjectContext];
managedObjectContext = moc;
// Setup a level-0 node for this Org-file
fileNode = (Node*)[NSEntityDescription insertNewObjectForEntityForName:@"Node" inManagedObjectContext:managedObjectContext];
@@ -0,0 +1,22 @@
//
// PersistenceStack.swift
// MobileOrg
//
// Created by Mario Martelli on 28.04.17.
// Copyright © 2017 Mario Martelli. All rights reserved.
//
import Foundation
import CoreData
@objc final class PersistenceStack:NSObject {
static let shared = PersistenceStack()
var moc:NSManagedObjectContext
private override init() {
self.moc = AppInstance().managedObjectContext
}
}
@@ -28,6 +28,7 @@
#import "MobileOrgAppDelegate.h"
#import "DataUtils.h"
#import "GlobalUtils.h"
#import "MobileOrg-Swift.h"
@implementation SearchController
@@ -124,7 +125,7 @@ - (void)viewDidLoad {
- (void)performSearch:(NSString*)term {
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Node" inManagedObjectContext:[AppInstance() managedObjectContext]];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Node" inManagedObjectContext:PersistenceStack.shared.moc];
[request setEntity:entity];
NSNumber *predLevel = [[NSNumber alloc] initWithInt:0];
@@ -152,7 +153,7 @@ - (void)performSearch:(NSString*)term {
[predLevel release];
NSError *error;
NSMutableArray *mutableFetchResults = [[[AppInstance() managedObjectContext] executeFetchRequest:request error:&error] mutableCopy];
NSMutableArray *mutableFetchResults = [[PersistenceStack.shared.moc executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResults == nil) {
// TODO: Error
}
@@ -69,6 +69,11 @@ class SettingsController: UITableViewController {
} else {
self.lastSyncLabel.text = "Not yet synced"
}
if let password = Settings.instance().encryptionPassword {
self.encryptionTextField.text = password
}
self.tableView.reloadData()
self.tableView.setNeedsDisplay()
}
@@ -583,7 +583,7 @@ - (void)processOrgFile:(NSString*)orgFilename withLocalFile:(NSString*)localFile
// Lookup multithreaded coredata issues
//[NSThread detachNewThreadSelector:@selector(parse) toTarget:orgFileParser withObject:nil];
NSManagedObjectContext *moc = [AppInstance() managedObjectContext];
NSManagedObjectContext *moc = PersistenceStack.shared.moc;
[orgFileParser parse: moc];
// Pause the TransferManager, because otherwise it would try to download
@@ -650,7 +650,7 @@ - (void)doneParsingEditsForApplication {
// Handle notes
if (entity.noteId) {
Note *newNote = (Note*)[NSEntityDescription insertNewObjectForEntityForName:@"Note" inManagedObjectContext:[AppInstance() managedObjectContext]];
Note *newNote = (Note*)[NSEntityDescription insertNewObjectForEntityForName:@"Note" inManagedObjectContext:PersistenceStack.shared.moc];
[newNote setCreatedAt:entity.createdAt];
[newNote setNoteId:entity.noteId];
[newNote setLocallyModified:[NSNumber numberWithBool:false]];
@@ -78,11 +78,12 @@ import Foundation
guard !context.dummy else {
activeTransfer?.success = true
// requestFinished(activeTransfer)
if let transfer = activeTransfer {
requestFinished(transfer)
}
return
}
var request = URLRequest(url: context.remoteUrl, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 30)
if context.transferType == TransferTypeDownload {
request.httpMethod = "GET"
@@ -29,14 +29,15 @@
#import "FileChecksum.h"
#import "Settings.h"
#import "OutlineViewController.h"
#import "MobileOrg-Swift.h"
bool Save() {
NSError *error;
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Call save
if (![managedObjectContext save:&error]) {
@@ -55,7 +56,7 @@ void ClearAllFileChecksums() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -91,7 +92,7 @@ void ClearAllFileChecksums() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -126,7 +127,7 @@ void ClearAllFileChecksums() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Create an action if one didn't exit
FileChecksum *checksum = (FileChecksum*)[NSEntityDescription insertNewObjectForEntityForName:@"FileChecksum" inManagedObjectContext:managedObjectContext];
@@ -176,7 +177,7 @@ void ClearAllFileChecksums() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -216,7 +217,7 @@ void ClearAllFileChecksums() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -256,7 +257,7 @@ void ClearAllFileChecksums() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -296,7 +297,7 @@ void ClearAllFileChecksums() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -325,7 +326,7 @@ void DeleteNode(Node *node) {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
[managedObjectContext deleteObject:node];
@@ -338,7 +339,7 @@ void DeleteNodesWithFilename(NSString* filename) {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
while ((node = NodeWithFilename(filename))) {
[managedObjectContext deleteObject:node];
@@ -358,7 +359,7 @@ void DeleteAllNodes() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// First, try to find an existing action
for (LocalEditAction *action in AllLocalEditActionsForNode(node)) {
@@ -394,7 +395,7 @@ void DeleteAllNodes() {
NSSortDescriptor *sortDescriptor;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -430,7 +431,7 @@ void DeleteAllNodes() {
NSSortDescriptor *sortDescriptor;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -465,7 +466,7 @@ void DeleteAllNodes() {
int CountLocalEditActions() {
NSManagedObjectContext *managedObjectContext;
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity: [NSEntityDescription entityForName:@"LocalEditAction" inManagedObjectContext:managedObjectContext]];
@@ -506,7 +507,7 @@ void DeleteLocalEditActions() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -537,7 +538,7 @@ void DeleteLocalEditAction(LocalEditAction *action) {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
[managedObjectContext deleteObject:action];
@@ -556,7 +557,7 @@ void DeleteLocalEditAction(LocalEditAction *action) {
NSSortDescriptor *sortDescriptor;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -592,7 +593,7 @@ void DeleteLocalEditAction(LocalEditAction *action) {
NSPredicate *predicate;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -623,7 +624,7 @@ void DeleteLocalEditAction(LocalEditAction *action) {
int CountNotes() {
NSManagedObjectContext *managedObjectContext;
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity: [NSEntityDescription entityForName:@"Note" inManagedObjectContext:managedObjectContext]];
@@ -638,7 +639,7 @@ int CountNotes() {
int CountLocalNotes() {
NSManagedObjectContext *managedObjectContext;
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity: [NSEntityDescription entityForName:@"Note" inManagedObjectContext:managedObjectContext]];
@@ -663,7 +664,7 @@ void DeleteNotes() {
NSManagedObjectContext *managedObjectContext;
// Get our managedObjectContext
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
// Initialize a request
request = [NSFetchRequest new];
@@ -690,7 +691,7 @@ void DeleteNotes() {
bool LocalNoteWithModifications(NSString *noteId) {
NSManagedObjectContext *managedObjectContext;
managedObjectContext = [AppInstance() managedObjectContext];
managedObjectContext = PersistenceStack.shared.moc;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity: [NSEntityDescription entityForName:@"Note" inManagedObjectContext:managedObjectContext]];
Oops, something went wrong.

0 comments on commit d658acb

Please sign in to comment.