@implementation PithosAccount
@synthesize uniqueName, active, name;
-@synthesize syncActive, syncDirectoryPath, syncAccountsDictionary, syncLastCompleted, syncDaemon;
+@synthesize syncActive, syncDirectoryPath, syncAccountsDictionary, syncSkipHidden, syncLastCompleted, syncDaemon;
@synthesize serverURL, versionResource, loginResource, publicResource;
@synthesize authUser, authToken, storageURLPrefix, authURL, loginURLPrefix, publicURLPrefix;
@synthesize pithos, accountNode, sharingAccountsNode;
+ (id)pithosAccount {
PithosAccount *pithosAccount = [[[self alloc] init] autorelease];
pithosAccount.uniqueName = [NSString stringWithFormat:@"pithosAccount-%f", [NSDate timeIntervalSinceReferenceDate]];
+ pithosAccount.syncSkipHidden = YES;
pithosAccount.versionResource = [NSString stringWithString:@"v1"];
pithosAccount.loginResource = [NSString stringWithString:@"login"];
return pithosAccount;
}
- (NSString *)description {
- return [NSString stringWithFormat:@"uniqueName: %@, active: %d, name: %@, syncActive: %d, syncDirectoryPath: %@, syncAccountsDictionary: %@, syncLastCompleted: %@, serverURL: %@, versionResource: %@, loginResource: %@, publicResource: %@, authUser: %@, authToken: %@, storageURLPrefix: %@, authURL: %@, loginURLPrefix: %@, publicURLPrefix: %@",
- uniqueName, active, name, syncActive, syncDirectoryPath, syncAccountsDictionary, syncLastCompleted, serverURL, versionResource, loginResource, publicResource, authUser, authToken, storageURLPrefix, authURL, loginURLPrefix, publicURLPrefix];
+ return [NSString stringWithFormat:@"uniqueName: %@, active: %d, name: %@, syncActive: %d, syncDirectoryPath: %@, syncAccountsDictionary: %@, syncSkipHidden: %d, syncLastCompleted: %@, serverURL: %@, versionResource: %@, loginResource: %@, publicResource: %@, authUser: %@, authToken: %@, storageURLPrefix: %@, authURL: %@, loginURLPrefix: %@, publicURLPrefix: %@",
+ uniqueName, active, name, syncActive, syncDirectoryPath, syncAccountsDictionary, syncSkipHidden, syncLastCompleted, serverURL, versionResource, loginResource, publicResource, authUser, authToken, storageURLPrefix, authURL, loginURLPrefix, publicURLPrefix];
}
#pragma mark -
- (void)setSyncAccountsDictionary:(NSMutableDictionary *)aSyncAccountsDictionary {
if (aSyncAccountsDictionary && ![self.syncAccountsDictionary isEqualToDictionary:aSyncAccountsDictionary]) {
[syncAccountsDictionary release];
- syncAccountsDictionary = [aSyncAccountsDictionary retain];
- // Validity of the dictionary is checked when loading from user defaults, and when modified in preferences
+ syncAccountsDictionary = [[NSMutableDictionary alloc] initWithCapacity:[aSyncAccountsDictionary count]];
+ for (NSString *accountName in aSyncAccountsDictionary) {
+ NSDictionary *aSyncContainersDictionary = [aSyncAccountsDictionary objectForKey:accountName];
+ NSMutableDictionary *syncContainersDictionary = [NSMutableDictionary dictionary];
+ for (NSString *containerName in aSyncContainersDictionary) {
+ if (![accountName isEqualToString:@""] || ![[containerName lowercaseString] isEqualToString:@"shared to me"])
+ [syncContainersDictionary setObject:[NSMutableSet setWithSet:[aSyncContainersDictionary objectForKey:containerName]]
+ forKey:containerName];
+ }
+ if ([syncContainersDictionary count])
+ [syncAccountsDictionary setObject:syncContainersDictionary forKey:accountName];
+ }
@synchronized(self) {
resetSyncDaemonLocalState = YES;
@synchronized(self) {
if (self.syncActive && !syncDaemon)
syncDaemon = [[PithosSyncDaemon alloc] initWithDirectoryPath:self.syncDirectoryPath
- pithosAccount:self
- accountsDictionary:self.syncAccountsDictionary
+ pithosAccount:self
+ accountsDictionary:self.syncAccountsDictionary
+ skipHidden:self.syncSkipHidden
resetLocalState:resetSyncDaemonLocalState];
resetSyncDaemonLocalState = NO;
}
pithos.storageURLPrefix = self.storageURLPrefix;
pithos.authURL = self.authURL;
pithos.publicURLPrefix = self.publicURLPrefix;
-
- if (accountNode && ![accountNode.pithos isEqualTo:pithos]) {
- accountNode.pithos = pithos;
- if (active)
- [accountNode refreshInfo];
- }
- if (sharingAccountsNode && ![sharingAccountsNode.pithos isEqualTo:pithos])
- sharingAccountsNode.pithos = pithos;
-
updatePithos = NO;
}
}
if (self.syncActive)
[self.syncDaemon startDaemon];
}
+ if (accountNode)
+ self.accountNode.pithos = self.pithos;
+ if (sharingAccountsNode)
+ self.sharingAccountsNode.pithos = self.pithos;
+ if (accountNode) {
+ if (self.accountNode.children) {
+ }
+ [self.accountNode refreshInfo];
+ }
+ if (sharingAccountsNode && self.sharingAccountsNode.children) {
+ }
}
}
- (void)updateSyncWithSyncActive:(BOOL)aSyncActive
syncDirectoryPath:(NSString *)aSyncDirectoryPath
- syncAccountsDictionary:(NSMutableDictionary *)aSyncAccountsDictionary {
+ syncAccountsDictionary:(NSMutableDictionary *)aSyncAccountsDictionary
+ syncSkipHidden:(BOOL)aSyncSkipHidden {
self.syncAccountsDictionary = aSyncAccountsDictionary;
self.syncDirectoryPath = aSyncDirectoryPath;
+ self.syncSkipHidden = aSyncSkipHidden;
self.syncActive = aSyncActive;
if (syncDaemon) {
self.syncDaemon.accountsDictionary = self.syncAccountsDictionary;
self.syncDaemon.directoryPath = self.syncDirectoryPath;
+ self.syncDaemon.skipHidden = self.syncSkipHidden;
if (self.syncActive)
[self.syncDaemon startDaemon];
}
self.syncActive = [decoder decodeBoolForKey:@"syncActive"];
self.syncDirectoryPath = [decoder decodeObjectForKey:@"syncDirectoryPath"];
- NSDictionary *immutableAccountsDictionary = [decoder decodeObjectForKey:@"syncAccountsDictionary"];
- syncAccountsDictionary = [[NSMutableDictionary alloc] initWithCapacity:[immutableAccountsDictionary count]];
- for (NSString *accountName in immutableAccountsDictionary) {
- NSDictionary *immutableContainersDictionary = [immutableAccountsDictionary objectForKey:accountName];
- NSMutableDictionary *syncContainersDictionary = [NSMutableDictionary dictionary];
- for (NSString *containerName in [immutableAccountsDictionary objectForKey:accountName]) {
- if (![accountName isEqualToString:@""] || ![[containerName lowercaseString] isEqualToString:@"shared to me"])
- [syncContainersDictionary setObject:[NSMutableSet setWithSet:[immutableContainersDictionary objectForKey:containerName]]
- forKey:containerName];
- }
- if ([syncContainersDictionary count])
- [syncAccountsDictionary setObject:syncContainersDictionary forKey:accountName];
- }
+ self.syncAccountsDictionary = [decoder decodeObjectForKey:@"syncAccountsDictionary"];
+ self.syncSkipHidden = [decoder decodeBoolForKey:@"syncSkipHidden"];
self.syncLastCompleted = [decoder decodeObjectForKey:@"syncLastCompleted"];
self.serverURL = [decoder decodeObjectForKey:@"serverURL"];
[encoder encodeBool:syncActive forKey:@"syncActive"];
[encoder encodeObject:syncDirectoryPath forKey:@"syncDirectoryPath"];
[encoder encodeObject:syncAccountsDictionary forKey:@"syncAccountsDictionary"];
+ [encoder encodeBool:syncSkipHidden forKey:@"syncSkipHidden"];
[encoder encodeObject:self.syncLastCompleted forKey:@"syncLastCompleted"];
[encoder encodeObject:serverURL forKey:@"serverURL"];