Permalink
Browse files

warn about synchronization feedback loops when setting the DB folder …

…location
  • Loading branch information...
1 parent 26ad1c4 commit 1fc136df68d6d3a2bc47b448a0d88cfaeab079e7 Zachary Schneirov committed Feb 7, 2010
View
BIN English.lproj/Localizable.strings
Binary file not shown.
View
12 French.lproj/Localizable.strings
@@ -353,6 +353,12 @@
/* No comment provided by engineer. */
"Individual files remain in the notes directory. Leave them alone or move them to the Trash?" = "Les fichiers individuels restent dans le dossier des notes. Faut-il les y laisser, ou les déplacer dans la Corbeille ?";
+/* no comment */
+"<Feedback loop warning title>" = "Warning: this notes folder is being synchronized with both %@ and %@. If other copies of Notational Velocity use the same notes folder, then a feedback loop will be created.";
+
+/* no comment */
+"<Feedback loop warning message>" = "To avoid this problem, choose a different location for the notes folder on this computer, or turn off %@ synchronization.";
+
/* No comment provided by engineer. */
"The %@ server holds a different set of notes. Replace all %u notes in Notational Velocity with the %u notes on the server, or merge both sets together?" = "Le serveur %@ contient un jeu différent de notes. Faut-il remplacer toutes les %u notes dans Notational Velocity avec les %u notes du serveur, ou bien faut-il fusionner les deux jeux ensemble ?";
@@ -392,6 +398,12 @@
/* human-readable name for the Simplenote service */
"Simplenote" = "Simplenote";
+/* human-readable name for the SimpleText service */
+"SimpleText" = "SimpleText";
+
+/* human-readable name for Dropbox */
+"Dropbox" = "Dropbox";
+
/* status text when downloading a note from the remote sync server */
"Downloading %u of %u notes" = "Télécharge %u sur %u notes";
View
2 NotationPrefs.h
@@ -104,6 +104,8 @@ NSMutableDictionary *ServiceAccountDictInit(NotationPrefs *prefs, NSString* serv
- (void)removeSyncPasswordForService:(NSString*)serviceName;
- (void)setKeyLengthInBits:(unsigned int)newLength;
+- (void)checkForKnownRedundantSyncConduitsAtPath:(NSString*)dbPath;
+
+ (NSString*)pathExtensionForFormat:(int)format;
//used to view tableviews
View
33 NotationPrefs.m
@@ -9,6 +9,8 @@
#import "NotationPrefs.h"
#import "GlobalPrefs.h"
#import "NSString_NV.h"
+#import "SimplenoteSession.h"
+#import "NSCollection_utils.h"
#import "NotationPrefsViewController.h"
#import "NSData_transformations.h"
#include <Carbon/Carbon.h>
@@ -766,6 +768,37 @@ - (void)removeSyncPasswordForService:(NSString*)serviceName {
}
}
+- (void)checkForKnownRedundantSyncConduitsAtPath:(NSString*)dbPath {
+ //is inside dropbox folder and notes are separate files
+ //is set to sync with any service
+ //then display warning
+
+ NSArray *enabledValues = [[syncServiceAccounts allValues] objectsFromDictionariesForKey:@"enabled"];
+ if ([enabledValues containsObject:[NSNumber numberWithBool:YES]] && SingleDatabaseFormat != notesStorageFormat) {
+ //this DB is syncing with a service and is storing separate files; could it be syncing with anything else, too?
+
+ //this logic will need to be more sophisticated anyway when multiple sync services are supported
+ NSString *syncServiceTitle = [SimplenoteSession localizedServiceTitle];
+
+ NSDictionary *stDict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.hogbaysoftware.SimpleText"];
+ NSString *simpleTextFolder = [stDict objectForKey:@"SyncedDocumentsPathKey"];
+ if (!simpleTextFolder) simpleTextFolder = [NSHomeDirectory() stringByAppendingPathComponent:@"SimpleText"];
+ //for dropbox, a 'select value from config where key = "dropbox_path";' sqlite query would be necessary to get the true path
+ NSString *dropboxFolder = [NSHomeDirectory() stringByAppendingPathComponent:@"Dropbox"];
+
+ NSString *offendingFileConduitName = nil;
+ if ([[dbPath lowercaseString] hasPrefix:[simpleTextFolder lowercaseString]]) {
+ offendingFileConduitName = NSLocalizedString(@"SimpleText", nil);
+ } else if ([[dbPath lowercaseString] hasPrefix:[dropboxFolder lowercaseString]]) {
+ offendingFileConduitName = NSLocalizedString(@"Dropbox", nil);
+ }
+ if (offendingFileConduitName) {
+ NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"<Feedback loop warning title>", nil), offendingFileConduitName, syncServiceTitle],
+ [NSString stringWithFormat:NSLocalizedString(@"<Feedback loop warning message>", nil), syncServiceTitle], NSLocalizedString(@"OK", nil), nil, nil);
+ }
+ }
+}
+
- (void)setKeyLengthInBits:(unsigned int)newLength {
//can't do this because we don't have password string
/*keyLengthInBits = newLength;
View
10 PrefsWindowController.m
@@ -231,18 +231,22 @@ - (NSMenu*)directorySelectionMenu {
- (void)changeDefaultDirectory {
FSRef notesDirectoryRef;
NSData *aliasData = nil;
+ NSString *directoryPath = nil;
- if ([self getNewNotesRefFromOpenPanel:&notesDirectoryRef returnedPath:nil]) {
+ if ([self getNewNotesRefFromOpenPanel:&notesDirectoryRef returnedPath:&directoryPath]) {
//make sure we're not choosing the same folder as what we started with, because:
//-[NotationController initWithAliasData:] might attempt to initialize journaling, which will already be in use
FSRef currentNotesDirectoryRef;
[[prefsController aliasDataForDefaultDirectory] fsRefAsAlias:&currentNotesDirectoryRef];
if (FSCompareFSRefs(&notesDirectoryRef, &currentNotesDirectoryRef) != noErr) {
- if ((aliasData = [NSData aliasDataForFSRef:&notesDirectoryRef]))
+ if ((aliasData = [NSData aliasDataForFSRef:&notesDirectoryRef])) {
[prefsController setAliasDataForDefaultDirectory:aliasData sender:self];
-
+
+ //check for potential synchronization problems; (e.g., simplenote w/ dropbox or writeroom):
+ [[prefsController notationPrefs] checkForKnownRedundantSyncConduitsAtPath:directoryPath];
+ }
} else {
NSLog(@"This folder is already chosen!");
}

0 comments on commit 1fc136d

Please sign in to comment.