OSX AFSBackgrounder fix minor bug
[openafs.git] / src / platform / DARWIN / AFSPreference / AFSPropertyManager.h
1 //
2 //  AFSPropertyManager.h
3 //  AFSCommander
4 //
5 //  Created by Claudio Bisegni on 21/05/07.
6 //  Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
7 //
8
9 #import <Cocoa/Cocoa.h>
10 #import "DBCellElement.h"
11 #import "FileUtil.h"
12
13 /*!
14     @class              AFSPropertyManager
15     @abstract   AFS Manage Class
16     @discussion This class manage the openafs param for celldbserv, cache param, group creation, get and release token
17 */
18
19 @interface AFSPropertyManager : NSObject {
20         NSString *installationPath;
21         NSString *cellName;
22         NSMutableArray *cellList;
23         NSArray *userDefaultCellArray;
24         NSString *afsRootMountPoint;
25         int statCacheEntry;
26         int dCacheDim;
27         int     cacheDimension;
28         int daemonNumber;
29         int nVolEntry;
30         bool dynRoot;
31         bool afsDB;
32         bool verbose;
33         
34         //-------------------
35         FileUtil *futil;
36         BOOL useAfsdConfVersion;
37 }
38
39 /*!
40     @method     
41     @abstract   (brief description)
42     @discussion (comprehensive description)
43 */
44 -(id) init;
45
46 /*!
47 @function       initWithAfsPath
48  @abstract   (description)
49  @discussion (description)
50  @param      path Path di installazione afs
51  @result     Istanza della classe di gestione delle propieta' afs
52  */
53 - (id)initWithAfsPath:(NSString*)path;
54
55 /*!
56     @method     
57     @abstract   (brief description)
58     @discussion (comprehensive description)
59 */
60 -(void) dealloc;
61 /*!
62  @method     
63  @abstract   (brief description)
64  @discussion (comprehensive description)
65  */
66 -(NSMutableArray*) getCellList;
67
68
69 /*!
70  @method     
71  @abstract   (brief description)
72  @discussion (comprehensive description)
73  */
74 -(NSArray*) getAllCellsName;
75 /*!
76  @method     
77  @abstract   (brief description)
78  @discussion (comprehensive description)
79  */
80 -(NSArray*) getUserDefaultForTokenCells;
81 /*!
82  @method     
83  @abstract   (brief description)
84  @discussion (comprehensive description)
85  */
86 -(NSArray*) getDefaultForTokenCellsName;
87 /*!
88  @method     
89  @abstract   (brief description)
90  @discussion (comprehensive description)
91  */
92 -(NSString*) getDefaultCellName;
93
94 /*!
95  @method     setDefaultCellByName
96  @abstract   set the cell named "name" to be se user default
97  @discussion first clean the last one selected as default and then  set the cell named "name" as default user cell
98  */
99 -(void) setDefaultCellByName:(NSString*)name;
100
101 /*!
102  @method     
103  @abstract   (brief description)
104  @discussion (comprehensive description)
105  */- (void) setCellName:(NSString*)cell;
106
107 /*!
108     @method     setPath
109     @abstract   Imposta Path
110     @discussion Imposta il path dove e' installato afs, in modo da leggere e scrivere le configurazioni
111 */
112 -(void) setPath:(NSString*)path;
113
114 /*!
115     @method     path
116     @abstract   Return the afs base
117     @discussion Return the Afs base installation path
118 */
119 -(NSString*) path;
120
121 /*!
122  @function       statCacheEntry
123  @abstract   get the afs number of state cache entry
124  @discussion 
125  @result     Number of stat cache entry
126  */
127 -(int) statCacheEntry;
128
129
130 /*!
131  @function       setStatCacheEntry
132  @abstract   Set the afs number of state cache entry
133  @discussion 
134  @result     Number of stat cache entry
135  */
136 -(void) setStatCacheEntry:(int)statEntry;
137
138 /*!
139 @function       dCacheDim
140 @abstract   return the dCacheDim param value for cache manager
141 @result     dCacheDim value
142 */
143 -(int) dCacheDim;
144
145 /*!
146  @function       setDCacheDim
147  @abstract   set the setDCacheDim value for cache manager param
148  @discussion <#(description)#>
149  @param      dcacheDim cache param value
150  */
151 -(void) setDCacheDim:(int)dcacheDim;
152
153 /*!
154  @function       cacheDimension
155  @abstract   return the max size of the cache 
156  @result     Cache  dimension
157  */
158 -(int) cacheDimension;
159
160 /*!
161  @function      setCacheDimension
162  @abstract   Set the max cache dimension
163  @discussion 
164  @param      cacheDim MAx Chace dimension
165  */
166 -(void) setCacheDimension:(int)cacheDim;
167
168 /*!
169  @function       daemonNumber
170  @abstract   Return the number of daemon for the cache manager
171  @result     Number of daemon
172  */
173 -(int) daemonNumber;
174
175 /*!
176  @function       setDaemonNumber
177  @abstract   Set the daemon numbero for the cache manager
178  @param      dNumber number of daemon
179  */
180 -(void) setDaemonNumber:(int)dNumber;
181
182 /*!
183  @function       afsRootMountPoint
184  @abstract   Return the path where afs root volume will be mounted
185  @result     AFS mount point
186  */
187 -(NSString*) afsRootMountPoint;
188
189 /*!
190  @function       setAfsRootMountPoint
191  @abstract   Set the AFS mount point
192  @param      mountPoint AFS mount point
193  */
194 -(void) setAfsRootMountPoint:(NSString*)mountPoint;
195
196 /*!
197  @function       nVolEntry
198  @abstract   Return the nVolEntry for cache manager
199  @result     value for nVolEntry cache parameter
200  */
201 -(int) nVolEntry;
202
203 /*!
204  @function       setNVolEntry
205  @abstract   Set the nVolEntry parameter for cache manager
206  @param      entry value for nVolEntry cache manager parameter
207  */
208 -(void) setNVolEntry:(int)entry;
209
210 /*!
211  @function       dynRoot
212  @abstract   Return the DynRoot parametr for cache manager
213  @result     dynRoot parameter value
214  */
215 -(bool) dynRoot;
216
217 /*!
218  @function       setDynRoot
219  @abstract   Set the DynRoot flag value for cache manager
220  @param      flag dynRoot state (enable/disable)
221  */
222 -(void) setDynRoot:(bool)flag;
223 /*!
224  @function       afsDB
225  @abstract   Get the afsdb flag value for cache manager
226  @result     Return the value of the flag
227  */
228 -(bool) afsDB;
229
230 /*!
231  @function       setAfsDB
232  @abstract   Set the flag value for afsdb cache manager
233  @param      flag AfsDB state (enable/disable)
234  */
235 -(void) setAfsDB:(bool)flag;
236 /*!
237  @function       verbose
238  */
239 -(bool) verbose;
240
241 /*!
242  @function       setVerbose
243  */
244 -(void) setVerbose:(bool)flag;
245 /*!
246  @function       readCacheInfo
247  @abstract   Read the cache info
248  @discussion The cache info is read from the file pointed by filePath param
249  @param      filePath file location for the CacheInfo
250  */
251 -(void) readCacheInfo:(NSString*)filePath;
252
253 /*!
254  @function       writeCacheInfo
255  @abstract   Write the cache info down the file
256  @param      filePath where to write the CacheInfo
257  @result     return the execution error
258  */
259 -(int) writeCacheInfo:(NSString*)filePath;
260
261 /*!
262  @function       readAfsdOption
263  @abstract   Read the afs option
264  @discussion Read the afs option checking firt the afs version so it can read the old afsd.option or afs.conf file. If any error accour an NSException wil be trown
265  @param      filePath file where the parameter are store for default afsd.option or afs.conf
266  */
267 -(void) readAfsdOption:(NSString*)filePath;
268
269 /*!
270  @function       readOldAfsdOption
271  @abstract   Read the afsd.option file
272  @discussion Read the old afsd.option style afsd option file. If any error accour an NSException wil be trown22
273  @param      filePath file path to afsd.option like file
274  @result     <#(description)#>
275  */
276 -(void) readOldAfsdOption:(NSString*)filePath;
277 /*!
278  @function       readAFSDParamLineContent
279  @abstract   Try to decode one line of afsd.option or afs.conf
280  @param      paramLine one line of file afsd.option(the only one that is present) os afs.conf
281  */
282 -(void) readAFSDParamLineContent:(NSString*)paramLine;
283 /*!
284  @function       readNewAfsdOption
285  @abstract   Read the new afs.conf file format
286  @discussion Scann every line f the afs.conf file ad for each one call the readAFSDParamLineContent with it's content
287  @param      filePath path of the new file with afs.conf file format
288  */
289 -(void) readNewAfsdOption:(NSString*)filePath;
290 /*!
291  @function       writeAfsdOption
292  @abstract   <#(description)#>
293  @discussion <#(description)#>
294  @param      <#(name) (description)#>
295  @result     <#(description)#>
296  */
297 -(int) writeAfsdOption:(NSString*)filePath;
298 /*!
299  @function       writeOldAfsdOption
300  @abstract   Write the cache manager parameter to file
301  @discussion First chech the version of afs installed then choice to save old o new file version(afsd.option or afs.conf)
302  @param      filePath file path for file to write into
303  @result     <#(description)#>
304  */
305 -(int) writeOldAfsdOption:(NSString*)filePath;
306 /*!
307  @function       writeNewAfsdOption
308  @abstract   Write the cache parameter to a file with the new format
309  @param      filePath file path where write into
310  */
311 -(int) writeNewAfsdOption:(NSString*)filePath;
312 /*!
313  @function       getAfsVersion
314  @abstract   Return the string representing the afs version
315  @result     The Enteir string returned from the call of fs -version
316  */
317 -(NSString*) getAfsVersion;
318 /*!
319  @function       getAfsMajorVersionVersion
320  @abstract   Return the major version of afs Major.x.x
321  @result     
322  */
323 -(int) getAfsMajorVersionVersion;
324 /*!
325  @function       getAfsMinorVersionVersion
326  @abstract   Return the major version of afs x.Minor.x
327  @result     
328  */
329 -(int) getAfsMinorVersionVersion;
330
331 /*!
332  @function       getAfsPatchVersionVersion
333  @abstract   Return the major version of afs x.x.Patch
334  @result     
335  */
336 -(int) getAfsPatchVersionVersion;
337
338 /*!
339  @method     clearConfiguration
340  @abstract   Clear all structure or array that contain value for afs client setting(cells cache param etch)
341  @discussion 
342          */
343 -(void) clearConfiguration;
344
345 /*!
346  @function       exceptionOnInvalidPath
347  @abstract   Check the validity of afs path
348  @discussion If the installationPath variable don't point to a valid path, will be fired an NSException
349  */
350 -(void) exceptionOnInvalidPath;
351
352 /*!
353     @method     loadConfiguration
354     @abstract   load the all afs configuration (ThisCell & CellServDB & cache parameter)
355 */
356 -(void) loadConfiguration;
357
358 /*!
359     @method     readCellInfo
360     @abstract   Read the Main Cell Name
361 */
362 -(void) readCellInfo:(NSString*) configFile;
363 /*!
364     @method     readCellDB
365     @abstract   Read the CellServDB File
366     @discussion Read the file of all cellservbd ad make the NSArray containing a DBCellElement for aech cell found
367 */
368 -(void) readCellDB:(NSString*) configFile;
369 /*!
370     @function   readTheseCell
371     @abstract   Read the "These Cell"
372     @discussion Read the "These Cell" file that contains all the cell from which the user want to get the token
373     @param      configFile TheseCell file path
374     @result     NSAray with the cells name
375 */
376 -(NSArray*) readTheseCell:(NSString*) configFile;
377 /*!
378     @method     shutdown
379     @abstract   Stop The AFS
380 */
381 -(void) shutdown;
382
383 -(void) scanIpForCell:(DBCellElement*) cellElement allIP:(NSString*)allIP;
384 -(void) backupConfigurationFiles;
385 -(void) backupFile:(NSString*)localAfsFilePath;
386 -(void) saveConfigurationFiles:(BOOL) makeBackup;
387 -(void) saveCacheConfigurationFiles:(BOOL) makeBackup;
388 -(void) installConfigurationFile:(NSString*)srcConfFile destPath:(NSString*) destPath;
389 -(NSArray*) getTokenList;
390 -(BOOL) checkAfsStatus;
391 -(void) klog:(NSString*)uName uPwd:(NSString*)uPwd  cell:(NSString*)theCell;
392 -(void) aklog:(NSString*)theCell noKerberosCall:(BOOL)krb5CallEnable;
393 -(void) getTokens:(BOOL)klogAklogFlag usr:(NSString*)usr pwd:(NSString*)pwd;
394 -(void) unlog:(NSString*)cell;
395 -(NSString*) makeChaceParamString;
396 -(BOOL) useAfsdConfConfigFile;
397 @end