Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 118 lines (100 sloc) 4.242 kB
0139b6c @jerrykrinock First commit
authored
1 #import <Cocoa/Cocoa.h>
2
3 extern NSString* const SSYDropboxGuyErrorDomain ;
4
5 @interface SSYDropboxGuy : NSObject
6
7 /*!
8 @brief Returns the icon of the Dropbox application, or the
9 system icon named "NSNetwork" if the Dropbox application is not
10 properly installed on current Mac.
11 */
12 + (NSImage*)dropboxIcon ;
13
14 /*!
15 @brief Opens the getdropbox.com website in the user's default
16 web browser and activates said web browser
17
18 @details This is used to help the user sign up for a
19 Dropbox account.
20 */
21 + (void)getDropbox ;
22
23 /*!
24 @brief Returns whether or not a given path is in the Dropbox
25 archive, indicating that it was replaced by Dropbox.
26 */
27 + (BOOL)wasReplacedByDropboxPath:(NSString*)path ;
28
29 /*!
30 @brief Blocks until the Dropbox application appears to be not busy.
31
32 @details The criteria used is that first the CPU usage of the Dropbox
33 application, returned by /bin/ps, is measured once per 2 seconds for 10
34 seconds. If the average of these five measurements is less than 1.0 percent,
35 then three more measurements are taken at 1-second intervals. If all
36 three of these are less than 0.25 percent, then isIdle_p is set to point
37 to YES and the method returns. If either of these tests fail, then
38 they are repeated, and this continues until the timeout.
39
40 When Dropbox is idle, this method usually returns the affirmative result
41 after 13-39 seconds. When Dropbox is receiving a file, it will not
42 return an affirmative result until Dropbox is idle. Also when Time
43 Machine is doing a backup, this usually keeps Dropbox active enough
44 to not return an affirmative result for a minute or two. But you
45 probably don't want to be messing with Dropbox while Time Machine
46 is doing its thing anyhow.
47
48 This method sleeps the thread between measurements, so it's not a
49 CPU hog, just a thread hog.
50
51 @param timeout time to wait for Dropbox to become idle. However,
52 one measurement cycle, which takes about 15 seconds, will always
53 execute. So this method will always block for at least about 15
54 seconds no matter what value you pass here.
55 @param isIdle_p Pointer which will, upon return, if not nil,
56 point to YES if Dropbox is idle and no error occurred
57 @param error_p Pointer which will, upon return, if the method
58 was not able to determine isIdle_p and error_p is not
59 NULL, point to an NSError describing said error.
60 @result YES if the method was able to set isIdle_p,
61 otherwise NO.
62 */
63 + (BOOL)waitForIdleDropboxTimeout:(NSTimeInterval)samplePeriod
64 isIdle:(BOOL*)isIdle_p
65 error_p:(NSError**)error_p ;
66
635ac55 @jerrykrinock Bug fixes and improvements
authored
67 + (NSString*)defaultDropboxPath ;
68
69 + (BOOL)dropboxIsAvailable ;
70
71 #if 0
72 /*
73 The following methods no longer work if user has Dropbox 1.2 or later, because
74 Dropbox has encrypted their configuration database. Sorry!
75 */
76 /*!
77 @brief Gets the path to the current user's Dropbox directory
78 @details Determined by reading the user's Dropbox database file.
79 @param error_p Pointer to an NSError* or NULL. Upon return,
80 if value is not NULL and if an error occurred while
81 reading the user's Dropbox database, the pointer will be set to
82 an NSError describing said error. Otherwise, if value is not NULL,
83 pointer will be set to nil.
84 @result If the user has a Dropbox database which can be read without
85 error, returns the user's Dropbox path. Otherwise, returns nil.
86 */
87 + (NSString*)dropboxPathError_p:(NSError**)error_p ;
88 /*!
89 @brief Returns whether or not the user has a Dropbox available.
90 @param error_p Pointer which will, upon return, if an error
91 occurred and said pointer is not NULL, point to an NSError
92 describing said error.
93 @result If an error occurs, the result is not defined.
94 */
95 + (BOOL)userHasDropboxError_p:(NSError**)error_p ;
0139b6c @jerrykrinock First commit
authored
96 /*!
97 @brief Returns whether or not a given path is in the user's
98 Dropbox folder
99 @param path The path in question. May be nil.
100 @result Whether or not the given path is in the user's Dropbox
101 folder. If no Dropbox folder, or if path is nil, returns NO.
102 */
103 + (BOOL)pathIsInDropbox:(NSString*)path ;
635ac55 @jerrykrinock Bug fixes and improvements
authored
104 #endif
0139b6c @jerrykrinock First commit
authored
105
106 @end
107
108
109 /* Test Code
110
111 while (YES) {
112 BOOL isIdle ;
113 NSError* error = nil ;
114 BOOL ok = [SSYDropboxGuy waitForIdleDropboxTimeout:(NSTimeInterval)300
115 isIdle:&isIdle
116 error_p:&error] ;
117 }
118 */
Something went wrong with that request. Please try again.