Improve UUID translation in nodes
[pithos-macos] / pithos-macos / PithosAccount.h
1 //
2 //  PithosAccount.h
3 //  pithos-macos
4 //
5 // Copyright 2012 GRNET S.A. All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or
8 // without modification, are permitted provided that the following
9 // conditions are met:
10 // 
11 //   1. Redistributions of source code must retain the above
12 //      copyright notice, this list of conditions and the following
13 //      disclaimer.
14 // 
15 //   2. Redistributions in binary form must reproduce the above
16 //      copyright notice, this list of conditions and the following
17 //      disclaimer in the documentation and/or other materials
18 //      provided with the distribution.
19 // 
20 // THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
21 // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
24 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 // USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 // POSSIBILITY OF SUCH DAMAGE.
32 // 
33 // The views and conclusions contained in the software and
34 // documentation are those of the authors and should not be
35 // interpreted as representing official policies, either expressed
36 // or implied, of GRNET S.A.
37
38 #import <Foundation/Foundation.h>
39 @class PithosSyncDaemon;
40 @class ASIPithos;
41 @class ASIPithosRequest;
42 @class PithosAccountNode;
43 @class PithosSharingAccountsNode;
44
45 @interface PithosAccount : NSObject <NSCoding> {
46     NSString *uniqueName;
47     BOOL active;
48     NSString *name;
49     NSString *clientVersion;
50     
51     BOOL syncActive;
52     NSString *syncDirectoryPath;
53     NSMutableDictionary *syncAccountsDictionary;
54     BOOL syncSkipHidden;
55     NSDate *syncLastCompleted;
56     PithosSyncDaemon *syncDaemon;
57         
58     // Base for all necessary URLs, default "https://pithos.okeanos.grnet.gr"
59     NSString *serverURL;
60     // Appended to serverURL to get storageURLPrefix and authURL, default "v1"
61     // Can be overriden by setting directly storageURLPrefix and authURL
62     NSString *versionResource;
63     // Appended to serverURL to get loginURLPrefix, default "login"
64     // Can be overriden by setting directly loginURLPrefix
65     NSString *loginResource;
66     // Appended to serverURL to get publicURLPrefix, default nil
67     // Can be overriden by setting directly publicURLPrefix
68     NSString *publicResource;
69     // Appended to serverURL to get userCatalogURL, default "user_catalogs"
70     // Can be overriden by setting directly userCatalogURL
71     NSString *userCatalogResource;
72
73     NSString *authUser;
74     NSString *authToken;
75     NSString *storageURLPrefix;
76     NSString *authURL;
77     NSString *publicURLPrefix;
78     NSString *loginURLPrefix;
79     NSString *userCatalogURL;
80     NSMutableDictionary *userCatalog;
81     
82     ASIPithos *pithos;
83     PithosAccountNode *accountNode;
84     PithosSharingAccountsNode *sharingAccountsNode;
85     
86     BOOL updatePithos;
87     BOOL resetSyncDaemonLocalState;
88 }
89
90 @property (nonatomic, strong) NSString *uniqueName;
91 @property (assign) BOOL active;
92 @property (nonatomic, strong) NSString *name;
93 @property (nonatomic, strong) NSString *clientVersion;
94
95 @property (nonatomic, assign) BOOL syncActive;
96 @property (nonatomic, strong) NSString *syncDirectoryPath;
97 @property (nonatomic, strong) NSMutableDictionary *syncAccountsDictionary;
98 @property (nonatomic, assign) BOOL syncSkipHidden;
99 @property (nonatomic, strong) NSDate *syncLastCompleted;
100 @property (nonatomic, strong) PithosSyncDaemon *syncDaemon;
101
102 @property (nonatomic, strong) NSString *serverURL;
103 @property (nonatomic, strong) NSString *versionResource;
104 @property (nonatomic, strong) NSString *loginResource;
105 @property (strong) NSString *publicResource;
106 @property (nonatomic, strong) NSString *userCatalogResource;
107
108 @property (nonatomic, strong) NSString *authUser;
109 @property (nonatomic, strong) NSString *authToken;
110 @property (nonatomic, strong) NSString *storageURLPrefix;
111 @property (nonatomic, strong) NSString *authURL;
112 @property (nonatomic, strong) NSString *publicURLPrefix;
113 @property (nonatomic, strong) NSString *loginURLPrefix;
114 @property (nonatomic, strong) NSString *userCatalogURL;
115 @property (nonatomic, strong) NSMutableDictionary *userCatalog;
116
117 @property (strong, readonly) ASIPithos *pithos;
118 @property (readonly) PithosAccountNode *accountNode;
119 @property (readonly) PithosSharingAccountsNode *sharingAccountsNode;
120
121 + (id)pithosAccount;
122
123 - (BOOL)urlIsValid:(NSString *)urlString;
124 - (void)authenticateWithServerURL:(NSString *)aServerURL authUser:(NSString *)anAuthUser authToken:(NSString *)anAuthToken;
125 - (void)loginWithServerURL:(NSString *)aServerURL;
126 - (void)updateSyncWithSyncActive:(BOOL)aSyncActive 
127                syncDirectoryPath:(NSString *)aSyncDirectoryPath 
128           syncAccountsDictionary:(NSMutableDictionary *)aSyncAccountsDictionary 
129                   syncSkipHidden:(BOOL)aSyncSkipHidden;
130 - (ASIPithosRequest *)updateUserCatalogForForDisplaynames:(NSArray *)displaynames UUIDs:(NSArray *)UUIDs;
131 - (NSString *)displaynameForUUID:(NSString *)UUID safe:(BOOL)safe;
132 - (NSString *)displaynameForUUID:(NSString *)UUID;
133
134 @end