Sync with "shared to me" selected accounts.
[pithos-macos] / pithos-macos / PithosSyncDaemon.h
index dfd3d77..49a2a2d 100644 (file)
@@ -2,7 +2,7 @@
 //  PithosSyncDaemon.h
 //  pithos-macos
 //
-// Copyright 2011 GRNET S.A. All rights reserved.
+// Copyright 2011-2012 GRNET S.A. All rights reserved.
 //
 // Redistribution and use in source and binary forms, with or
 // without modification, are permitted provided that the following
 // or implied, of GRNET S.A.
 
 #import <Foundation/Foundation.h>
+@class PithosAccount;
+@class ASIPithos;
 @class PithosActivityFacility;
 @class ASINetworkQueue;
 
 @interface PithosSyncDaemon : NSObject {
     NSString *directoryPath;
-    NSString *containerName;
-    NSTimeInterval timeInterval;
+    PithosAccount *pithosAccount;
+    NSDictionary *accountsDictionary;
+    ASIPithos *pithos;
 
-    NSString *blockHash;
-    NSUInteger blockSize;
-    NSDate *lastModified;
+    NSUInteger accountsCount;
+    NSMutableArray *accountsNames;
+    NSUInteger accountsIndex;
+    NSMutableDictionary *accountsPithosContainers;
+    NSUInteger containersIndex;
+    
     NSMutableArray *objects;
     NSMutableDictionary *remoteObjects;
+    NSMutableDictionary *previousRemoteObjects;
     NSMutableDictionary *storedLocalObjectStates;
     NSMutableDictionary *currentLocalObjectStates;
     
-    NSString *containerDirectoryPath;
     NSString *pithosStateFilePath;
     NSString *tempDownloadsDirPath;
     NSString *tempTrashDirPath;
     
+    BOOL daemonActive;
+    
     NSUInteger syncOperationCount;
     BOOL newSyncRequested;
     NSDate *lastCompletedSync;
     BOOL syncIncomplete;
+    BOOL syncLate;
     
-    ASINetworkQueue *queue;
-    NSTimer *timer;
+    ASINetworkQueue *networkQueue;
+    NSOperationQueue *callbackQueue;
     
     PithosActivityFacility *activityFacility;
 }
 
-@property (nonatomic, retain) NSString *blockHash;
-@property (nonatomic, assign) NSUInteger blockSize;
-@property (nonatomic, retain) NSDate *lastModified;
+@property (nonatomic, retain) NSString *directoryPath;
+@property (nonatomic, retain) NSDictionary *accountsDictionary;
+@property (nonatomic, retain) ASIPithos *pithos;
+
+@property (nonatomic, retain) NSMutableArray *accountsNames;
+@property (nonatomic, retain) NSMutableDictionary *accountsPithosContainers;
+
 @property (nonatomic, retain) NSMutableDictionary *remoteObjects;
+@property (nonatomic, retain) NSMutableDictionary *previousRemoteObjects;
 @property (nonatomic, retain) NSMutableDictionary *storedLocalObjectStates;
 @property (nonatomic, retain) NSMutableDictionary *currentLocalObjectStates;
 
-@property (nonatomic, readonly) NSString *directoryPath;
-@property (nonatomic, readonly) NSString *containerDirectoryPath;
 @property (nonatomic, readonly) NSString *pithosStateFilePath;
 @property (nonatomic, readonly) NSString *tempDownloadsDirPath;
 @property (nonatomic, readonly) NSString *tempTrashDirPath;
 
 @property (nonatomic, retain) NSDate *lastCompletedSync;
 
+// accountsDictionary contains entries of the form
+// { <included sharing account name> : { <included container name> : [ <excluded directory names> ] } }
+// <included sharing account name> :
+//     the empty string "" denotes the user's own account
+// <excluded directory names> : 
+//     the empty string "" denotes all file objects in the container root
+//     non-empty strings denote also container root file objects with these names
+// Case insensitive filesystem is assumed, so directory names should be in lowercase
+// and any trailing '/' should be replaced by ':'
 - (id)initWithDirectoryPath:(NSString *)aDirectoryPath 
-              containerName:(NSString *)aContainerName 
-               timeInterval:(NSTimeInterval)aTimeInterval;
+              pithosAccount:(PithosAccount *)aPithosAccount 
+         accountsDictionary:(NSDictionary *)anAccountsDictionary 
+            resetLocalState:(BOOL)resetLocalState;
+
+- (void)resetDaemon;
+- (void)startDaemon;
+
 - (void)sync;
+- (BOOL)isSyncing;
+- (void)syncLate;
 
 @end