When there are not username and token provided during startup, preferences are shown.
[pithos-macos] / pithos-macos / pithos_macosAppDelegate.m
index 61889fb..d6d06c4 100644 (file)
     NSString *authToken = [userDefaults stringForKey:@"authToken"];
     NSString *syncDirectoryPath = [userDefaults stringForKey:@"pithosSyncDirectoryPath"];
     NSLog(@"Authentication - storageURLPrefix:%@, authUser:%@, authToken:%@", storageURLPrefix, authUser, authToken);
-    if ([authUser length] && [authToken length] && 
-        (![[ASIPithosRequest authUser] isEqualToString:authUser] || ![[ASIPithosRequest authToken] isEqualToString:authToken])) {
+    if (([authUser length] == 0) || ([authToken length] == 0)) {
+        [self showPithosPreferences:self];
+    } else if ([authUser length] && [authToken length] && 
+               (![[ASIPithosRequest authUser] isEqualToString:authUser] || ![[ASIPithosRequest authToken] isEqualToString:authToken])) {
         [[ASIDownloadCache sharedCache] clearCachedResponsesForStoragePolicy:ASICacheForSessionDurationCacheStoragePolicy];
         [[ASIPithosRequest sharedQueue] cancelAllOperations];
         
                                                                  resetLocalState:NO] autorelease];
         
         [[NSNotificationCenter defaultCenter] postNotificationName:@"PithosAuthenticationCredentialsUpdated" object:self];
-        return;
-    }
-    if (![pithosSyncDaemon.directoryPath isEqualToString:syncDirectoryPath])
+    } else if (![pithosSyncDaemon.directoryPath isEqualToString:syncDirectoryPath]) {
         self.pithosSyncDaemon = [[[PithosSyncDaemon alloc] initWithDirectoryPath:syncDirectoryPath 
                                                                    containerName:syncContainerName 
                                                                     timeInterval:syncTimeInterval 
                                                                  resetLocalState:YES] autorelease];
+    }
 }
 
 @end