Skip to content

Commit

Permalink
Fixed CoreData → Yap account migration
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchiles committed Nov 20, 2014
1 parent b57fc0e commit 17231a8
Show file tree
Hide file tree
Showing 80 changed files with 861 additions and 2,233 deletions.
452 changes: 219 additions & 233 deletions ChatSecure.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

20 changes: 2 additions & 18 deletions ChatSecure/Classes/Controllers/OTRDatabaseManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#import "OTRManagedFacebookAccount.h"
#import "OTRGoogleOAuthXMPPAccount.h"
#import "OTRFacebookOAuthXMPPAccount.h"
#import "OTRManagedXMPPTorAccount.h"
#import "OTRAccount.h"
#import "CoreData+MagicalRecord.h"
#import "OTRMessage.h"
Expand Down Expand Up @@ -75,29 +74,18 @@ - (void)migrateCoreDataToYapDatabase
{
NSURL *mom2 = [[NSBundle mainBundle] URLForResource:@"ChatSecure 2" withExtension:@"mom" subdirectory:@"ChatSecure.momd"];
NSURL *mom3 = [[NSBundle mainBundle] URLForResource:@"ChatSecure 3" withExtension:@"mom" subdirectory:@"ChatSecure.momd"];
NSURL *mom4 = [[NSBundle mainBundle] URLForResource:@"ChatSecure 4" withExtension:@"mom" subdirectory:@"ChatSecure.momd"];
NSManagedObjectModel *version2Model = [[NSManagedObjectModel alloc] initWithContentsOfURL:mom2];
NSManagedObjectModel *version3Model = [[NSManagedObjectModel alloc] initWithContentsOfURL:mom3];
NSManagedObjectModel *version4Model = [[NSManagedObjectModel alloc] initWithContentsOfURL:mom4];

if ([OTRDatabaseManager isManagedObjectModel:version2Model compatibleWithStoreAtUrl:databaseURL]) {

}
else if ([OTRDatabaseManager isManagedObjectModel:version3Model compatibleWithStoreAtUrl:databaseURL]) {

}
else if ([OTRDatabaseManager isManagedObjectModel:version4Model compatibleWithStoreAtUrl:databaseURL]) {

[OTRDatabaseManager migrateLegacyStore:databaseURL destinationStore:databaseURL sourceModel:version2Model destinationModel:version3Model error:nil];
}


[MagicalRecord setShouldAutoCreateManagedObjectModel:NO];
[MagicalRecord setDefaultModelNamed:@"ChatSecure.momd"];
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:@"ChatSecure.sqlite"];

//[OTREncryptionManager setFileProtection:NSFileProtectionCompleteUntilFirstUserAuthentication path:databaseURL.path];
//[OTREncryptionManager addSkipBackupAttributeToItemAtURL:databaseURL];

////// Migrate core data to yapdatabase //////

NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
Expand All @@ -118,7 +106,7 @@ - (void)migrateCoreDataToYapDatabase
}];
}];


[[NSFileManager defaultManager] removeItemAtURL:databaseURL error:nil];
}

[OTRDatabaseManager deleteLegacyXMPPFiles];
Expand All @@ -140,7 +128,6 @@ - (OTRAccount *)accountWithCoreDataAccount:(OTRManagedAccount *)managedAccount
account.displayName = accountDictionary[OTRManagedAccountAttributes.displayName];
account.domain = accountDictionary[OTRManagedXMPPAccountAttributes.domain];
account.port = [accountDictionary[OTRManagedXMPPAccountAttributes.port] intValue];
account.resource = accountDictionary[OTRManagedXMPPAccountAttributes.resource];

////// transfer saved passwords //////

Expand Down Expand Up @@ -169,9 +156,6 @@ - (OTRAccountType)accountTypeWithCoreDataClass:(NSString *)coreDataClass
if ([coreDataClass isEqualToString:NSStringFromClass([OTRManagedXMPPAccount class])]) {
return OTRAccountTypeJabber;
}
else if ([coreDataClass isEqualToString:NSStringFromClass([OTRManagedXMPPTorAccount class])]) {
return OTRAccountTypeXMPPTor;
}
else if ([coreDataClass isEqualToString:NSStringFromClass([OTRManagedGoogleAccount class])]) {
return OTRAccountTypeGoogleTalk;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>ChatSecure 4.xcdatamodel</string>
<string>ChatSecure 3.xcdatamodel</string>
</dict>
</plist>

This file was deleted.

28 changes: 2 additions & 26 deletions ChatSecure/Classes/Model/Core Data/Human/OTRManagedBuddy.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
//
// OTRManagedBuddy.h
// Off the Record
//
// Created by Christopher Ballinger on 1/10/13.
// Copyright (c) 2013 Chris Ballinger. All rights reserved.
//
// This file is part of ChatSecure.
//
// ChatSecure is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ChatSecure is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ChatSecure. If not, see <http://www.gnu.org/licenses/>.

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "_OTRManagedBuddy.h"

@interface OTRManagedBuddy : _OTRManagedBuddy

@interface OTRManagedBuddy : _OTRManagedBuddy {}
// Custom logic goes here.
@end
29 changes: 7 additions & 22 deletions ChatSecure/Classes/Model/Core Data/Human/OTRManagedBuddy.m
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
//
// OTRManagedBuddy.m
// Off the Record
//
// Created by Christopher Ballinger on 1/10/13.
// Copyright (c) 2013 Chris Ballinger. All rights reserved.
//
// This file is part of ChatSecure.
//
// ChatSecure is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ChatSecure is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ChatSecure. If not, see <http://www.gnu.org/licenses/>.

#import "OTRManagedBuddy.h"

@interface OTRManagedBuddy ()

// Private interface goes here.

@end

@implementation OTRManagedBuddy

// Custom logic goes here.

@end

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "_OTRManagedEncryptionStatusMessage.h"

@interface OTRManagedEncryptionStatusMessage : _OTRManagedEncryptionStatusMessage {}
// Custom logic goes here.
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "OTRManagedEncryptionStatusMessage.h"

@interface OTRManagedEncryptionStatusMessage ()

// Private interface goes here.

@end

@implementation OTRManagedEncryptionStatusMessage

// Custom logic goes here.

@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "_OTRmanagedFacebookAccount.h"
#import "_OTRManagedFacebookAccount.h"

@interface OTRManagedFacebookAccount : _OTRManagedFacebookAccount
@interface OTRManagedFacebookAccount : _OTRManagedFacebookAccount {}
// Custom logic goes here.
@end
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#import "OTRmanagedFacebookAccount.h"

#import "OTRManagedFacebookAccount.h"

@interface OTRManagedFacebookAccount ()

// Private interface goes here.

@end


@implementation OTRManagedFacebookAccount

// Custom logic goes here.

@end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "_OTRManagedGoogleAccount.h"

@interface OTRManagedGoogleAccount : _OTRManagedGoogleAccount
@interface OTRManagedGoogleAccount : _OTRManagedGoogleAccount {}
// Custom logic goes here.
@end
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ @interface OTRManagedGoogleAccount ()

@end


@implementation OTRManagedGoogleAccount

// Custom logic goes here.

@end
3 changes: 1 addition & 2 deletions ChatSecure/Classes/Model/Core Data/Human/OTRManagedGroup.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#import "_OTRManagedGroup.h"

@interface OTRManagedGroup : _OTRManagedGroup {}


// Custom logic goes here.
@end
6 changes: 4 additions & 2 deletions ChatSecure/Classes/Model/Core Data/Human/OTRManagedGroup.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#import "OTRManagedGroup.h"
#import "OTRLog.h"

@interface OTRManagedGroup ()

@end
// Private interface goes here.

@end

@implementation OTRManagedGroup

// Custom logic goes here.

@end
28 changes: 2 additions & 26 deletions ChatSecure/Classes/Model/Core Data/Human/OTRManagedMessage.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
//
// OTRManagedMessage.h
// Off the Record
//
// Created by Christopher Ballinger on 1/10/13.
// Copyright (c) 2013 Chris Ballinger. All rights reserved.
//
// This file is part of ChatSecure.
//
// ChatSecure is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ChatSecure is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with ChatSecure. If not, see <http://www.gnu.org/licenses/>.

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "_OTRManagedMessage.h"

@interface OTRManagedMessage : _OTRManagedMessage

@interface OTRManagedMessage : _OTRManagedMessage {}
// Custom logic goes here.
@end
Loading

0 comments on commit 17231a8

Please sign in to comment.