rhodes 7.4.1 → 7.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +5 -5
  2. data/CREDITS +3 -1
  3. data/LICENSE +1 -1
  4. data/README.md +3 -1
  5. data/Rakefile +52 -43
  6. data/SECURITY.md +19 -0
  7. data/appveyor.yml +60 -7
  8. data/azure-pipelines.yml +67 -0
  9. data/extensions/rhoconnect-push/ext/rhoconnect-push/platform/android/src/com/rhomobile/rhoelements/ans/ANSManager.java +2 -2
  10. data/lib/commonAPI/barcode/ext/platform/android/AndroidManifest.xml +3 -1
  11. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/BarcodeCaptureActivity.java +11 -13
  12. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/BarcodeGraphicTracker.java +1 -1
  13. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/ui/camera/CameraSource.java +3 -3
  14. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/ui/camera/CameraSourcePreview.java +1 -1
  15. data/lib/commonAPI/barcode/ext.yml +4 -8
  16. data/lib/commonAPI/coreapi/ext/platform/android/Rakefile +0 -12
  17. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/Notification.java +4 -2
  18. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationScheduler.java +3 -3
  19. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationSingleton.java +1 -1
  20. data/lib/commonAPI/coreapi/ext/push.xml +5 -2
  21. data/lib/commonAPI/mediacapture/ext/camera.xml +4 -9
  22. data/lib/commonAPI/mediacapture/ext/platform/android/ApplicationFileProvider.erb +1 -1
  23. data/lib/commonAPI/mediacapture/ext/platform/android/ext_java.files +1 -9
  24. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraExtension.java +0 -2
  25. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java +19 -24
  26. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraObject.java +317 -729
  27. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraRhoListener.java +240 -434
  28. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/{CameraSingletonObject.java → CameraSingleton.java} +68 -74
  29. data/lib/commonAPI/printing_zebra/ext/platform/android/src/com/rhomobile/printing/zebra/impl/ZebraPrintingProviderImpl.java +2 -1
  30. data/lib/extensions/fcm-push/ext/android/ApplicationManifestAdds.erb +15 -17
  31. data/lib/extensions/fcm-push/ext/android/Rakefile +59 -34
  32. data/lib/extensions/fcm-push/ext/android/ext_java.files +0 -1
  33. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMFacade.java +13 -17
  34. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMIntentService.java +81 -80
  35. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMListener.java +0 -16
  36. data/lib/extensions/fcm-push/ext.yml +1 -1
  37. data/lib/extensions/gmaps/ext/platform/android/ApplicationManifestAdds.erb +1 -0
  38. data/lib/extensions/gmaps/ext/platform/android/src/com/rhomobile/rhodes/gmaps/GMapActivity.java +12 -4
  39. data/lib/extensions/gmaps/ext.yml +3 -1
  40. data/platform/android/Rhodes/jni/src/MethodResultJni.cpp +4 -0
  41. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +3 -3
  42. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +3 -3
  43. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/StatusNotification.java +1 -1
  44. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +14 -14
  45. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +18 -9
  46. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality26.java +1 -1
  47. data/platform/android/build/{aab_builder.rb → aapt2_helper.rb} +94 -37
  48. data/platform/android/build/android.rake +124 -191
  49. data/platform/android/build/android_tools.rb +9 -9
  50. data/platform/android/build/androidcommon.rb +18 -7
  51. data/platform/android/build/build_tools_finder.rb +46 -0
  52. data/platform/android/build/config.yml +5 -0
  53. data/platform/android/build/dex_builder.rb +88 -0
  54. data/platform/android/build/hostplatform.rb +9 -0
  55. data/platform/android/build/manifest_generator.rb +1 -0
  56. data/platform/android/build/maven_deps_extractor.rb +22 -21
  57. data/platform/android/build/ndkwrapper.rb +80 -51
  58. data/platform/iphone/Classes/AppManager/AppManager.m +3 -1
  59. data/platform/iphone/Classes/Camera/PickImageDelegate.h +2 -0
  60. data/platform/iphone/Classes/Camera/PickImageDelegate.m +45 -23
  61. data/platform/iphone/Classes/CocoaServer/CCocoaServer.h +27 -0
  62. data/platform/iphone/Classes/CocoaServer/CCocoaServer.m +107 -0
  63. data/platform/iphone/Classes/CocoaServer/RhoHTTPConnection.h +16 -0
  64. data/platform/iphone/Classes/CocoaServer/RhoHTTPConnection.m +226 -0
  65. data/platform/iphone/Classes/RhoWKWebView.mm +78 -11
  66. data/platform/iphone/Classes/RhoWebViewFabrique.m +6 -1
  67. data/platform/iphone/Classes/Rhodes.m +3 -0
  68. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDData.h +14 -0
  69. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDData.m +158 -0
  70. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDNumber.h +12 -0
  71. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDNumber.m +88 -0
  72. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDRange.h +56 -0
  73. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDRange.m +104 -0
  74. data/platform/iphone/CocoaHTTPServer/Core/HTTPAuthenticationRequest.h +45 -0
  75. data/platform/iphone/CocoaHTTPServer/Core/HTTPAuthenticationRequest.m +195 -0
  76. data/platform/iphone/CocoaHTTPServer/Core/HTTPConnection.h +120 -0
  77. data/platform/iphone/CocoaHTTPServer/Core/HTTPConnection.m +2708 -0
  78. data/platform/iphone/CocoaHTTPServer/Core/HTTPLogging.h +136 -0
  79. data/platform/iphone/CocoaHTTPServer/Core/HTTPMessage.h +48 -0
  80. data/platform/iphone/CocoaHTTPServer/Core/HTTPMessage.m +113 -0
  81. data/platform/iphone/CocoaHTTPServer/Core/HTTPResponse.h +149 -0
  82. data/platform/iphone/CocoaHTTPServer/Core/HTTPServer.h +205 -0
  83. data/platform/iphone/CocoaHTTPServer/Core/HTTPServer.m +772 -0
  84. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.h +65 -0
  85. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.m +529 -0
  86. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.h +33 -0
  87. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.m +86 -0
  88. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.h +23 -0
  89. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.m +211 -0
  90. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.h +75 -0
  91. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.m +405 -0
  92. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDataResponse.h +13 -0
  93. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDataResponse.m +79 -0
  94. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.h +52 -0
  95. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.m +292 -0
  96. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.h +9 -0
  97. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.m +38 -0
  98. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPFileResponse.h +25 -0
  99. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPFileResponse.m +237 -0
  100. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.h +12 -0
  101. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.m +73 -0
  102. data/platform/iphone/CocoaHTTPServer/Core/WebSocket.h +105 -0
  103. data/platform/iphone/CocoaHTTPServer/Core/WebSocket.m +791 -0
  104. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.h +7 -0
  105. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.m +160 -0
  106. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.h +11 -0
  107. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.m +372 -0
  108. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.h +7 -0
  109. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.m +49 -0
  110. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.h +8 -0
  111. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.m +69 -0
  112. data/platform/iphone/CocoaHTTPServer/LICENSE.txt +18 -0
  113. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/About.txt +4 -0
  114. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.h +1226 -0
  115. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m +8528 -0
  116. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/About.txt +33 -0
  117. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.h +41 -0
  118. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.m +99 -0
  119. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
  120. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.m +727 -0
  121. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDFileLogger.h +334 -0
  122. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDFileLogger.m +1353 -0
  123. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDLog.h +601 -0
  124. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDLog.m +1083 -0
  125. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDTTYLogger.h +167 -0
  126. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDTTYLogger.m +1479 -0
  127. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
  128. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
  129. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
  130. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
  131. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/README.txt +7 -0
  132. data/platform/iphone/Framework/Rhodes/Rhodes.xcodeproj/project.pbxproj +1 -1
  133. data/platform/iphone/RhoAppBaseLib/RhoAppBaseLib.xcodeproj/project.pbxproj +364 -0
  134. data/platform/iphone/rbuild/iphone.rake +4 -0
  135. data/platform/osx/bin/RhoSimulator/RhoSimulator.app.zip +0 -0
  136. data/platform/shared/common/RhodesApp.cpp +26 -1
  137. data/platform/shared/net/HttpServer.cpp +20 -0
  138. data/platform/shared/qt/RhoSimulator.pro +1 -1
  139. data/platform/shared/ruby/osx/ruby/config.h +2 -0
  140. data/platform/shared/ruby/win32/win32.c +10 -3
  141. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  142. data/rakefile.rb +52 -43
  143. data/res/build-tools/RhoRuby.exe +0 -0
  144. data/res/build-tools/aapt2/linux/aapt2 +0 -0
  145. data/res/build-tools/aapt2/osx/aapt2 +0 -0
  146. data/res/generators/templates/application/AndroidManifest.erb +2 -1
  147. data/res/generators/templates/application/build.yml +4 -1
  148. data/res/generators/templates/application/rhoconfig.txt +5 -0
  149. data/rhobuild.yml.example +4 -4
  150. data/rhodes.gemspec +1 -2
  151. data/version +1 -1
  152. metadata +80 -35
  153. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/drawable/camera_btn.xml +0 -14
  154. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/layout/camera_land.xml +0 -23
  155. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/layout/camera_port.xml +0 -23
  156. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraActivity.java +0 -156
  157. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraEclair.java +0 -227
  158. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraGingerbread.java +0 -152
  159. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraPreview.java +0 -183
  160. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonEclair.java +0 -14
  161. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonGingerbread.java +0 -60
  162. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/ICameraObject.java +0 -20
  163. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/ICameraSingletonObject.java +0 -8
  164. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMTokenRefresherService.java +0 -27
  165. data/platform/android/Rhodes/AndroidManifest.xml.erb +0 -89
@@ -0,0 +1,334 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import "DDLog.h"
3
+
4
+ @class DDLogFileInfo;
5
+
6
+ /**
7
+ * Welcome to Cocoa Lumberjack!
8
+ *
9
+ * The project page has a wealth of documentation if you have any questions.
10
+ * https://github.com/robbiehanson/CocoaLumberjack
11
+ *
12
+ * If you're new to the project you may wish to read the "Getting Started" wiki.
13
+ * https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
14
+ *
15
+ *
16
+ * This class provides a logger to write log statements to a file.
17
+ **/
18
+
19
+
20
+ // Default configuration and safety/sanity values.
21
+ //
22
+ // maximumFileSize -> DEFAULT_LOG_MAX_FILE_SIZE
23
+ // rollingFrequency -> DEFAULT_LOG_ROLLING_FREQUENCY
24
+ // maximumNumberOfLogFiles -> DEFAULT_LOG_MAX_NUM_LOG_FILES
25
+ //
26
+ // You should carefully consider the proper configuration values for your application.
27
+
28
+ #define DEFAULT_LOG_MAX_FILE_SIZE (1024 * 1024) // 1 MB
29
+ #define DEFAULT_LOG_ROLLING_FREQUENCY (60 * 60 * 24) // 24 Hours
30
+ #define DEFAULT_LOG_MAX_NUM_LOG_FILES (5) // 5 Files
31
+
32
+
33
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
34
+ #pragma mark -
35
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
36
+
37
+ // The LogFileManager protocol is designed to allow you to control all aspects of your log files.
38
+ //
39
+ // The primary purpose of this is to allow you to do something with the log files after they have been rolled.
40
+ // Perhaps you want to compress them to save disk space.
41
+ // Perhaps you want to upload them to an FTP server.
42
+ // Perhaps you want to run some analytics on the file.
43
+ //
44
+ // A default LogFileManager is, of course, provided.
45
+ // The default LogFileManager simply deletes old log files according to the maximumNumberOfLogFiles property.
46
+ //
47
+ // This protocol provides various methods to fetch the list of log files.
48
+ //
49
+ // There are two variants: sorted and unsorted.
50
+ // If sorting is not necessary, the unsorted variant is obviously faster.
51
+ // The sorted variant will return an array sorted by when the log files were created,
52
+ // with the most recently created log file at index 0, and the oldest log file at the end of the array.
53
+ //
54
+ // You can fetch only the log file paths (full path including name), log file names (name only),
55
+ // or an array of DDLogFileInfo objects.
56
+ // The DDLogFileInfo class is documented below, and provides a handy wrapper that
57
+ // gives you easy access to various file attributes such as the creation date or the file size.
58
+
59
+ @protocol DDLogFileManager <NSObject>
60
+ @required
61
+
62
+ // Public properties
63
+
64
+ /**
65
+ * The maximum number of archived log files to keep on disk.
66
+ * For example, if this property is set to 3,
67
+ * then the LogFileManager will only keep 3 archived log files (plus the current active log file) on disk.
68
+ * Once the active log file is rolled/archived, then the oldest of the existing 3 rolled/archived log files is deleted.
69
+ *
70
+ * You may optionally disable deleting old/rolled/archived log files by setting this property to zero.
71
+ **/
72
+ @property (readwrite, assign) NSUInteger maximumNumberOfLogFiles;
73
+
74
+ // Public methods
75
+
76
+ - (NSString *)logsDirectory;
77
+
78
+ - (NSArray *)unsortedLogFilePaths;
79
+ - (NSArray *)unsortedLogFileNames;
80
+ - (NSArray *)unsortedLogFileInfos;
81
+
82
+ - (NSArray *)sortedLogFilePaths;
83
+ - (NSArray *)sortedLogFileNames;
84
+ - (NSArray *)sortedLogFileInfos;
85
+
86
+ // Private methods (only to be used by DDFileLogger)
87
+
88
+ - (NSString *)createNewLogFile;
89
+
90
+ @optional
91
+
92
+ // Notifications from DDFileLogger
93
+
94
+ - (void)didArchiveLogFile:(NSString *)logFilePath;
95
+ - (void)didRollAndArchiveLogFile:(NSString *)logFilePath;
96
+
97
+ @end
98
+
99
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
100
+ #pragma mark -
101
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
102
+
103
+ /**
104
+ * Default log file manager.
105
+ *
106
+ * All log files are placed inside the logsDirectory.
107
+ * If a specific logsDirectory isn't specified, the default directory is used.
108
+ * On Mac, this is in ~/Library/Logs/<Application Name>.
109
+ * On iPhone, this is in ~/Library/Caches/Logs.
110
+ *
111
+ * Log files are named "log-<uuid>.txt",
112
+ * where uuid is a 6 character hexadecimal consisting of the set [0123456789ABCDEF].
113
+ *
114
+ * Archived log files are automatically deleted according to the maximumNumberOfLogFiles property.
115
+ **/
116
+ @interface DDLogFileManagerDefault : NSObject <DDLogFileManager>
117
+ {
118
+ NSUInteger maximumNumberOfLogFiles;
119
+ NSString *_logsDirectory;
120
+ }
121
+
122
+ - (id)init;
123
+ - (id)initWithLogsDirectory:(NSString *)logsDirectory;
124
+
125
+ /* Inherited from DDLogFileManager protocol:
126
+
127
+ @property (readwrite, assign) NSUInteger maximumNumberOfLogFiles;
128
+
129
+ - (NSString *)logsDirectory;
130
+
131
+ - (NSArray *)unsortedLogFilePaths;
132
+ - (NSArray *)unsortedLogFileNames;
133
+ - (NSArray *)unsortedLogFileInfos;
134
+
135
+ - (NSArray *)sortedLogFilePaths;
136
+ - (NSArray *)sortedLogFileNames;
137
+ - (NSArray *)sortedLogFileInfos;
138
+
139
+ */
140
+
141
+ @end
142
+
143
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
144
+ #pragma mark -
145
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
146
+
147
+ /**
148
+ * Most users will want file log messages to be prepended with the date and time.
149
+ * Rather than forcing the majority of users to write their own formatter,
150
+ * we will supply a logical default formatter.
151
+ * Users can easily replace this formatter with their own by invoking the setLogFormatter method.
152
+ * It can also be removed by calling setLogFormatter, and passing a nil parameter.
153
+ *
154
+ * In addition to the convenience of having a logical default formatter,
155
+ * it will also provide a template that makes it easy for developers to copy and change.
156
+ **/
157
+ @interface DDLogFileFormatterDefault : NSObject <DDLogFormatter>
158
+ {
159
+ NSDateFormatter *dateFormatter;
160
+ }
161
+
162
+ - (id)init;
163
+ - (id)initWithDateFormatter:(NSDateFormatter *)dateFormatter;
164
+
165
+ @end
166
+
167
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
168
+ #pragma mark -
169
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
170
+
171
+ @interface DDFileLogger : DDAbstractLogger <DDLogger>
172
+ {
173
+ __strong id <DDLogFileManager> logFileManager;
174
+
175
+ DDLogFileInfo *currentLogFileInfo;
176
+ NSFileHandle *currentLogFileHandle;
177
+
178
+ dispatch_source_t rollingTimer;
179
+
180
+ unsigned long long maximumFileSize;
181
+ NSTimeInterval rollingFrequency;
182
+ }
183
+
184
+ - (id)init;
185
+ - (id)initWithLogFileManager:(id <DDLogFileManager>)logFileManager;
186
+
187
+ /**
188
+ * Log File Rolling:
189
+ *
190
+ * maximumFileSize:
191
+ * The approximate maximum size to allow log files to grow.
192
+ * If a log file is larger than this value after a log statement is appended,
193
+ * then the log file is rolled.
194
+ *
195
+ * rollingFrequency
196
+ * How often to roll the log file.
197
+ * The frequency is given as an NSTimeInterval, which is a double that specifies the interval in seconds.
198
+ * Once the log file gets to be this old, it is rolled.
199
+ *
200
+ * Both the maximumFileSize and the rollingFrequency are used to manage rolling.
201
+ * Whichever occurs first will cause the log file to be rolled.
202
+ *
203
+ * For example:
204
+ * The rollingFrequency is 24 hours,
205
+ * but the log file surpasses the maximumFileSize after only 20 hours.
206
+ * The log file will be rolled at that 20 hour mark.
207
+ * A new log file will be created, and the 24 hour timer will be restarted.
208
+ *
209
+ * You may optionally disable rolling due to filesize by setting maximumFileSize to zero.
210
+ * If you do so, rolling is based solely on rollingFrequency.
211
+ *
212
+ * You may optionally disable rolling due to time by setting rollingFrequency to zero (or any non-positive number).
213
+ * If you do so, rolling is based solely on maximumFileSize.
214
+ *
215
+ * If you disable both maximumFileSize and rollingFrequency, then the log file won't ever be rolled.
216
+ * This is strongly discouraged.
217
+ **/
218
+ @property (readwrite, assign) unsigned long long maximumFileSize;
219
+ @property (readwrite, assign) NSTimeInterval rollingFrequency;
220
+
221
+ /**
222
+ * The DDLogFileManager instance can be used to retrieve the list of log files,
223
+ * and configure the maximum number of archived log files to keep.
224
+ *
225
+ * @see DDLogFileManager.maximumNumberOfLogFiles
226
+ **/
227
+ @property (strong, nonatomic, readonly) id <DDLogFileManager> logFileManager;
228
+
229
+
230
+ // You can optionally force the current log file to be rolled with this method.
231
+
232
+ - (void)rollLogFile;
233
+
234
+ // Inherited from DDAbstractLogger
235
+
236
+ // - (id <DDLogFormatter>)logFormatter;
237
+ // - (void)setLogFormatter:(id <DDLogFormatter>)formatter;
238
+
239
+ @end
240
+
241
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
242
+ #pragma mark -
243
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
244
+
245
+ /**
246
+ * DDLogFileInfo is a simple class that provides access to various file attributes.
247
+ * It provides good performance as it only fetches the information if requested,
248
+ * and it caches the information to prevent duplicate fetches.
249
+ *
250
+ * It was designed to provide quick snapshots of the current state of log files,
251
+ * and to help sort log files in an array.
252
+ *
253
+ * This class does not monitor the files, or update it's cached attribute values if the file changes on disk.
254
+ * This is not what the class was designed for.
255
+ *
256
+ * If you absolutely must get updated values,
257
+ * you can invoke the reset method which will clear the cache.
258
+ **/
259
+ @interface DDLogFileInfo : NSObject
260
+ {
261
+ __strong NSString *filePath;
262
+ __strong NSString *fileName;
263
+
264
+ __strong NSDictionary *fileAttributes;
265
+
266
+ __strong NSDate *creationDate;
267
+ __strong NSDate *modificationDate;
268
+
269
+ unsigned long long fileSize;
270
+ }
271
+
272
+ @property (strong, nonatomic, readonly) NSString *filePath;
273
+ @property (strong, nonatomic, readonly) NSString *fileName;
274
+
275
+ @property (strong, nonatomic, readonly) NSDictionary *fileAttributes;
276
+
277
+ @property (strong, nonatomic, readonly) NSDate *creationDate;
278
+ @property (strong, nonatomic, readonly) NSDate *modificationDate;
279
+
280
+ @property (nonatomic, readonly) unsigned long long fileSize;
281
+
282
+ @property (nonatomic, readonly) NSTimeInterval age;
283
+
284
+ @property (nonatomic, readwrite) BOOL isArchived;
285
+
286
+ + (id)logFileWithPath:(NSString *)filePath;
287
+
288
+ - (id)initWithFilePath:(NSString *)filePath;
289
+
290
+ - (void)reset;
291
+ - (void)renameFile:(NSString *)newFileName;
292
+
293
+ #if TARGET_IPHONE_SIMULATOR
294
+
295
+ // So here's the situation.
296
+ // Extended attributes are perfect for what we're trying to do here (marking files as archived).
297
+ // This is exactly what extended attributes were designed for.
298
+ //
299
+ // But Apple screws us over on the simulator.
300
+ // Everytime you build-and-go, they copy the application into a new folder on the hard drive,
301
+ // and as part of the process they strip extended attributes from our log files.
302
+ // Normally, a copy of a file preserves extended attributes.
303
+ // So obviously Apple has gone to great lengths to piss us off.
304
+ //
305
+ // Thus we use a slightly different tactic for marking log files as archived in the simulator.
306
+ // That way it "just works" and there's no confusion when testing.
307
+ //
308
+ // The difference in method names is indicative of the difference in functionality.
309
+ // On the simulator we add an attribute by appending a filename extension.
310
+ //
311
+ // For example:
312
+ // log-ABC123.txt -> log-ABC123.archived.txt
313
+
314
+ - (BOOL)hasExtensionAttributeWithName:(NSString *)attrName;
315
+
316
+ - (void)addExtensionAttributeWithName:(NSString *)attrName;
317
+ - (void)removeExtensionAttributeWithName:(NSString *)attrName;
318
+
319
+ #else
320
+
321
+ // Normal use of extended attributes used everywhere else,
322
+ // such as on Macs and on iPhone devices.
323
+
324
+ - (BOOL)hasExtendedAttributeWithName:(NSString *)attrName;
325
+
326
+ - (void)addExtendedAttributeWithName:(NSString *)attrName;
327
+ - (void)removeExtendedAttributeWithName:(NSString *)attrName;
328
+
329
+ #endif
330
+
331
+ - (NSComparisonResult)reverseCompareByCreationDate:(DDLogFileInfo *)another;
332
+ - (NSComparisonResult)reverseCompareByModificationDate:(DDLogFileInfo *)another;
333
+
334
+ @end