rhodes 7.4.1 → 7.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (305) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +319 -0
  3. data/CREDITS +3 -1
  4. data/LICENSE +1 -1
  5. data/README.md +6 -16
  6. data/Rakefile +55 -43
  7. data/SECURITY.md +19 -0
  8. data/appveyor.yml +66 -8
  9. data/azure-pipelines.yml +67 -0
  10. data/bin/rhodes-setup +22 -8
  11. data/extensions/emdk3-manager/ext/platform/android/src/com/rho/emdk3/EMDK3Extension.java +14 -5
  12. data/extensions/instrumentation/ext/platform/android/src/com/rho/instrumentation/Instrumentation.java +29 -15
  13. data/extensions/rhoconnect-push/ext/rhoconnect-push/platform/android/src/com/rhomobile/rhoelements/ans/ANSManager.java +3 -3
  14. data/extensions/rhoelementsext/ext/rhoelementsext/platform/android/rhoelements_temp/src/com/rho/rhoelements/ElementsCore.java +12 -9
  15. data/extensions/rhoelementsext/ext/rhoelementsext/platform/android/rhoelements_temp/src/com/rho/rhoelements/graphics/BatteryIndicator.java +2 -2
  16. data/lib/commonAPI/barcode/ext/platform/android/AndroidManifest.xml +3 -1
  17. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/BarcodeCaptureActivity.java +11 -13
  18. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/BarcodeGraphicTracker.java +1 -1
  19. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/ui/camera/CameraSource.java +3 -3
  20. data/lib/commonAPI/barcode/ext/platform/android/src/com/google/barcodereader/ui/camera/CameraSourcePreview.java +1 -1
  21. data/lib/commonAPI/barcode/ext/platform/qt/Barcode.pro +1 -1
  22. data/lib/commonAPI/barcode/ext/platform/qt/Barcode.pro.erb +2 -2
  23. data/lib/commonAPI/barcode/ext/platform/qt/src/qzxing/QZXing.pri +9 -21
  24. data/lib/commonAPI/barcode/ext.yml +5 -8
  25. data/lib/commonAPI/bluetooth/ext/platform/qt/Bluetooth.pro +1 -1
  26. data/lib/commonAPI/bluetooth/ext/platform/qt/Bluetooth.pro.erb +1 -1
  27. data/lib/commonAPI/bluetooth/ext/platform/qt/src/bluetooth/bluetoothhelper.h +1 -1
  28. data/lib/commonAPI/coreapi/RhoSystemApi.rb +6 -0
  29. data/lib/commonAPI/coreapi/ext/Intent.xml +4 -0
  30. data/lib/commonAPI/coreapi/ext/platform/android/Rakefile +0 -12
  31. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/intent/IntentSingleton.java +6 -0
  32. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/Notification.java +5 -2
  33. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationScheduler.java +4 -4
  34. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/notification/NotificationSingleton.java +1 -1
  35. data/lib/commonAPI/coreapi/ext/platform/android/src/com/rho/webview/WebViewSingleton.java +40 -27
  36. data/lib/commonAPI/coreapi/ext/platform/iphone/cpp_based_impl/SystemImpl.mm +5 -6
  37. data/lib/commonAPI/coreapi/ext/platform/iphone/impl/Intent.h +1 -1
  38. data/lib/commonAPI/coreapi/ext/platform/iphone/impl/Intent.m +3 -1
  39. data/lib/commonAPI/coreapi/ext/platform/iphone/impl/NotificationSingleton.h +2 -1
  40. data/lib/commonAPI/coreapi/ext/platform/iphone/impl/NotificationSingleton.m +10 -0
  41. data/lib/commonAPI/coreapi/ext/platform/wm/src/IntentImpl.cpp +3 -0
  42. data/lib/commonAPI/coreapi/ext/push.xml +5 -2
  43. data/lib/commonAPI/coreapi/ext/shared/SystemImplBase.cpp +13 -0
  44. data/lib/commonAPI/coreapi/ext/shared/SystemImplBase.h +2 -0
  45. data/lib/commonAPI/coreapi/ext/system.xml +3 -0
  46. data/lib/commonAPI/mediacapture/ext/camera.xml +4 -9
  47. data/lib/commonAPI/mediacapture/ext/platform/android/ApplicationCameraActivity.erb +2 -2
  48. data/lib/commonAPI/mediacapture/ext/platform/android/ApplicationFileProvider.erb +1 -1
  49. data/lib/commonAPI/mediacapture/ext/platform/android/ext_java.files +2 -9
  50. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraExtension.java +0 -2
  51. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraFactory.java +19 -24
  52. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraObject.java +322 -730
  53. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraRhoListener.java +247 -433
  54. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/{CameraSingletonObject.java → CameraSingleton.java} +68 -74
  55. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/mediacapture/RhoCameraFileProvider.java +6 -0
  56. data/lib/commonAPI/mediacapture/ext/platform/qt/MediaCapture.pro.erb +1 -1
  57. data/lib/commonAPI/mediacapture/ext/platform/qt/Mediacapture.pro +1 -1
  58. data/lib/commonAPI/printing_zebra/ext/platform/android/src/com/rhomobile/printing/zebra/impl/ZebraPrintingProviderImpl.java +2 -1
  59. data/lib/commonAPI/signature/ext/platform/iphone/impl/readme.txt +7 -0
  60. data/lib/commonAPI/signature/ext/platform/qt/Signature.pro +3 -10
  61. data/lib/commonAPI/signature/ext/platform/qt/Signature.pro.erb +2 -2
  62. data/lib/extensions/fcm-push/ext/android/ApplicationManifestAdds.erb +15 -17
  63. data/lib/extensions/fcm-push/ext/android/Rakefile +59 -34
  64. data/lib/extensions/fcm-push/ext/android/ext_java.files +0 -1
  65. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMFacade.java +13 -17
  66. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMIntentService.java +81 -80
  67. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMListener.java +0 -16
  68. data/lib/extensions/fcm-push/ext/iphone/Podfile +15 -2
  69. data/lib/extensions/fcm-push/ext/iphone/fcm-push.xcodeproj/project.pbxproj +6 -7
  70. data/lib/extensions/fcm-push/ext.yml +1 -1
  71. data/lib/extensions/gmaps/ext/platform/android/ApplicationManifestAdds.erb +1 -0
  72. data/lib/extensions/gmaps/ext/platform/android/src/com/rhomobile/rhodes/gmaps/GMapActivity.java +12 -4
  73. data/lib/extensions/gmaps/ext.yml +3 -1
  74. data/lib/extensions/nfc/ext/platform/android/src/com/rhomobile/nfc/Nfc.java +2 -1
  75. data/lib/extensions/serialport/ext/serialport.pro +1 -1
  76. data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +1 -0
  77. data/platform/android/Rhodes/jni/src/MethodResultJni.cpp +4 -0
  78. data/platform/android/Rhodes/jni/src/fileapi.cpp +4 -0
  79. data/platform/android/Rhodes/res/drawable/baseline_check_24.xml +5 -0
  80. data/platform/android/Rhodes/res/drawable/baseline_check_240.xml +5 -0
  81. data/platform/android/Rhodes/res/drawable/baseline_close_24.xml +5 -0
  82. data/platform/android/Rhodes/res/drawable/baseline_close_240.xml +5 -0
  83. data/platform/android/Rhodes/res/layout/overlay_layout.xml +39 -0
  84. data/platform/android/Rhodes/res/layout/perrmission_alert_dialog.xml +267 -0
  85. data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +183 -66
  86. data/platform/android/Rhodes/src/com/rhomobile/rhodes/LocalFileProvider.java +38 -6
  87. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoFileProvider.java +32 -0
  88. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +532 -92
  89. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +26 -4
  90. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +259 -163
  91. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/StatusNotification.java +1 -1
  92. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/AbstractRhoExtension.java +14 -3
  93. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtManager.java +4 -0
  94. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtension.java +5 -4
  95. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManagerImpl.java +79 -38
  96. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +20 -15
  97. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +18 -9
  98. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/CallReceiver.java +22 -0
  99. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/IKioskMode.java +11 -0
  100. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/KioskManager.java +18 -0
  101. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/MyAccessibilityService.java +230 -0
  102. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/MyNotificationListenerService.java +16 -0
  103. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/MyOverlayService.java +197 -0
  104. data/platform/android/Rhodes/src/com/rhomobile/rhodes/kioskservices/PermissionManager.java +232 -0
  105. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +34 -8
  106. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality26.java +1 -1
  107. data/platform/android/Rhodes/src/com/rhomobile/rhodes/permissioncheck/CheckDrawable.java +53 -0
  108. data/platform/android/Rhodes/src/com/rhomobile/rhodes/permissioncheck/PermissionListGenerate.java +366 -0
  109. data/platform/android/Rhodes/src/com/rhomobile/rhodes/rhodes.iml +11 -0
  110. data/platform/android/Rhodes/src/com/rhomobile/rhodes/socket/SSLImpl.java +1 -0
  111. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +782 -41
  112. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoInputConnectionWrapper.java +146 -0
  113. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoInputListener.java +21 -0
  114. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebViewClient.java +92 -32
  115. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/TauWebViewOptions.java +118 -0
  116. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/WebSettingsProviderBase.java +18 -17
  117. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/WebSettingsProviderEclairMR1.java +4 -4
  118. data/platform/android/build/RhodesSRC_build.files +13 -0
  119. data/platform/android/build/{aab_builder.rb → aapt2_helper.rb} +94 -37
  120. data/platform/android/build/android-repack.rake +8 -1
  121. data/platform/android/build/android.rake +238 -238
  122. data/platform/android/build/android_tools.rb +10 -10
  123. data/platform/android/build/androidcommon.rb +31 -14
  124. data/platform/android/build/build_tools_finder.rb +46 -0
  125. data/platform/android/build/config.yml +8 -0
  126. data/platform/android/build/dex_builder.rb +88 -0
  127. data/platform/android/build/hostplatform.rb +9 -0
  128. data/platform/android/build/manifest_generator.rb +15 -10
  129. data/platform/android/build/maven_deps_extractor.rb +29 -22
  130. data/platform/android/build/ndkwrapper.rb +92 -51
  131. data/platform/android/proguard/proguard-base-rules.pro +5 -0
  132. data/platform/android/proguard/proguard.jar +0 -0
  133. data/platform/iphone/Classes/AppManager/AppManager.m +3 -1
  134. data/platform/iphone/Classes/Camera/PickImageDelegate.h +2 -0
  135. data/platform/iphone/Classes/Camera/PickImageDelegate.m +45 -23
  136. data/platform/iphone/Classes/CocoaServer/CCocoaServer.h +27 -0
  137. data/platform/iphone/Classes/CocoaServer/CCocoaServer.m +107 -0
  138. data/platform/iphone/Classes/CocoaServer/RhoHTTPConnection.h +16 -0
  139. data/platform/iphone/Classes/CocoaServer/RhoHTTPConnection.m +226 -0
  140. data/platform/iphone/Classes/RhoAppBaseLib-Bridging-Header.h +4 -0
  141. data/platform/iphone/Classes/RhoAppBaseStandaloneLib-Bridging-Header.h +4 -0
  142. data/platform/iphone/Classes/RhoCryptAESGCM.swift +105 -0
  143. data/platform/iphone/Classes/RhoUIWebView.h +1 -1
  144. data/platform/iphone/Classes/RhoUIWebView.m +1 -1
  145. data/platform/iphone/Classes/RhoWKWebView.h +1 -1
  146. data/platform/iphone/Classes/RhoWKWebView.mm +110 -15
  147. data/platform/iphone/Classes/RhoWebView.h +1 -1
  148. data/platform/iphone/Classes/RhoWebViewFabrique.m +13 -2
  149. data/platform/iphone/Classes/Rhodes.m +3 -0
  150. data/platform/iphone/Classes/SimpleMainView.m +5 -5
  151. data/platform/iphone/Classes/URLProtocol/CRhoURLProtocol.m +21 -10
  152. data/platform/iphone/Classes/rho/net/IPhoneNetRequest.mm +4 -0
  153. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDData.h +14 -0
  154. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDData.m +158 -0
  155. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDNumber.h +12 -0
  156. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDNumber.m +88 -0
  157. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDRange.h +56 -0
  158. data/platform/iphone/CocoaHTTPServer/Core/Categories/DDRange.m +104 -0
  159. data/platform/iphone/CocoaHTTPServer/Core/HTTPAuthenticationRequest.h +45 -0
  160. data/platform/iphone/CocoaHTTPServer/Core/HTTPAuthenticationRequest.m +195 -0
  161. data/platform/iphone/CocoaHTTPServer/Core/HTTPConnection.h +120 -0
  162. data/platform/iphone/CocoaHTTPServer/Core/HTTPConnection.m +2708 -0
  163. data/platform/iphone/CocoaHTTPServer/Core/HTTPLogging.h +136 -0
  164. data/platform/iphone/CocoaHTTPServer/Core/HTTPMessage.h +48 -0
  165. data/platform/iphone/CocoaHTTPServer/Core/HTTPMessage.m +113 -0
  166. data/platform/iphone/CocoaHTTPServer/Core/HTTPResponse.h +149 -0
  167. data/platform/iphone/CocoaHTTPServer/Core/HTTPServer.h +205 -0
  168. data/platform/iphone/CocoaHTTPServer/Core/HTTPServer.m +772 -0
  169. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.h +65 -0
  170. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartFormDataParser.m +529 -0
  171. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.h +33 -0
  172. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeader.m +86 -0
  173. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.h +23 -0
  174. data/platform/iphone/CocoaHTTPServer/Core/Mime/MultipartMessageHeaderField.m +211 -0
  175. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.h +75 -0
  176. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPAsyncFileResponse.m +405 -0
  177. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDataResponse.h +13 -0
  178. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDataResponse.m +79 -0
  179. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.h +52 -0
  180. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPDynamicFileResponse.m +292 -0
  181. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.h +9 -0
  182. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPErrorResponse.m +38 -0
  183. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPFileResponse.h +25 -0
  184. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPFileResponse.m +237 -0
  185. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.h +12 -0
  186. data/platform/iphone/CocoaHTTPServer/Core/Responses/HTTPRedirectResponse.m +73 -0
  187. data/platform/iphone/CocoaHTTPServer/Core/WebSocket.h +105 -0
  188. data/platform/iphone/CocoaHTTPServer/Core/WebSocket.m +791 -0
  189. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.h +7 -0
  190. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVConnection.m +160 -0
  191. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.h +11 -0
  192. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DAVResponse.m +372 -0
  193. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.h +7 -0
  194. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/DELETEResponse.m +49 -0
  195. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.h +8 -0
  196. data/platform/iphone/CocoaHTTPServer/Extensions/WebDAV/PUTResponse.m +69 -0
  197. data/platform/iphone/CocoaHTTPServer/LICENSE.txt +18 -0
  198. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/About.txt +4 -0
  199. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.h +1226 -0
  200. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaAsyncSocket/GCDAsyncSocket.m +8528 -0
  201. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/About.txt +33 -0
  202. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.h +41 -0
  203. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDASLLogger.m +99 -0
  204. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
  205. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDAbstractDatabaseLogger.m +727 -0
  206. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDFileLogger.h +334 -0
  207. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDFileLogger.m +1353 -0
  208. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDLog.h +601 -0
  209. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDLog.m +1083 -0
  210. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDTTYLogger.h +167 -0
  211. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/DDTTYLogger.m +1479 -0
  212. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
  213. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
  214. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
  215. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
  216. data/platform/iphone/CocoaHTTPServer/Vendor/CocoaLumberjack/Extensions/README.txt +7 -0
  217. data/platform/iphone/Framework/RhoApplication/RhoApplication.xcodeproj/project.pbxproj +1 -1
  218. data/platform/iphone/Framework/Rhodes/Rhodes.xcodeproj/project.pbxproj +2 -2
  219. data/platform/iphone/RhoAppBaseLib/RhoAppBaseLib.xcodeproj/project.pbxproj +410 -1
  220. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +1 -1
  221. data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +4 -1
  222. data/platform/iphone/rbuild/iphone.rake +13 -8
  223. data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +4 -1
  224. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +1 -1
  225. data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +1 -1
  226. data/platform/osx/bin/RhoSimulator/RhoSimulator.app.zip +0 -0
  227. data/platform/sailfish/build/{harbour-SailfishRhodes.pro.erb → SailfishRhodes.pro.erb} +10 -17
  228. data/platform/sailfish/build/rhodes.pro.erb +7 -17
  229. data/platform/sailfish/build/rpm/SailfishRhodes.desktop.erb +12 -0
  230. data/platform/sailfish/build/rpm/SailfishRhodes.erb +2 -0
  231. data/platform/sailfish/build/rpm/SailfishRhodes.spec.erb +43 -0
  232. data/platform/sailfish/build/rubylib.pro.erb +29 -29
  233. data/platform/sailfish/build/sailfish.rake +188 -180
  234. data/platform/sailfish/keys/regular_cert.pem +14 -0
  235. data/platform/sailfish/keys/regular_key.pem +4 -0
  236. data/platform/shared/common/RhodesApp.cpp +59 -10
  237. data/platform/shared/common/iphone/RhoCryptImpl.mm +130 -54
  238. data/platform/shared/net/HttpServer.cpp +20 -0
  239. data/platform/shared/qt/RhoSimulator.pro +1 -1
  240. data/platform/shared/qt/rhodes/rhodes.pro +4 -11
  241. data/platform/shared/qt/sailfish/SailfishRhodes.desktop +3 -4
  242. data/platform/shared/qt/sailfish/SailfishRhodes.pro +9 -10
  243. data/platform/shared/qt/sailfish/icons/108x108/108x108.png +0 -0
  244. data/platform/shared/qt/sailfish/privileges/sailfishrhodes +2 -0
  245. data/platform/shared/qt/sailfish/qml/pages/FirstPageWK.qml +7 -11
  246. data/platform/shared/qt/sailfish/qml/{harbour-sailfishrhodes.qml → sailfishrhodes.qml} +1 -1
  247. data/platform/shared/qt/sailfish/rpm/sailfishrhodes.spec +80 -0
  248. data/platform/shared/qt/sailfish/rpm/{harbour-sailfishrhodes.yaml → sailfishrhodes.yaml} +2 -2
  249. data/platform/shared/qt/sailfish/src/QtMainWindow.cpp +1 -1
  250. data/platform/shared/qt/sailfish/src/QtMainWindow.h +1 -1
  251. data/platform/shared/qt/sailfish/src/main.cpp +6 -38
  252. data/platform/shared/qt/sailfish/src/rootdelegate.h +2 -14
  253. data/platform/shared/ruby/aurora/ruby/config.h +386 -0
  254. data/platform/shared/ruby/aurora/ruby/constdefs.c +5866 -0
  255. data/platform/shared/ruby/aurora/ruby/constdefs.h +1788 -0
  256. data/platform/shared/ruby/osx/ruby/config.h +2 -0
  257. data/platform/shared/ruby/win32/win32.c +10 -3
  258. data/platform/shared/sqlite/crypto.c +14 -0
  259. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  260. data/platform/win32/build/rhodes.nsi +3 -3
  261. data/platform/win32/build/win32.rake +1 -1
  262. data/rakefile.rb +55 -43
  263. data/res/build-tools/RhoRuby.exe +0 -0
  264. data/res/build-tools/aapt2/linux/aapt2 +0 -0
  265. data/res/build-tools/aapt2/osx/aapt2 +0 -0
  266. data/res/build-tools/iphonesim/build/Release/iphonesim_8 +4 -4
  267. data/res/generators/templates/application/AndroidManifest.erb +28 -6
  268. data/res/generators/templates/application/build.yml +18 -11
  269. data/res/generators/templates/application/resources/android/res/xml/provider_paths.xml +4 -0
  270. data/res/generators/templates/application/rhoconfig.txt +15 -1
  271. data/res/generators/templates/iphone_project/Bremen8.xcodeproj/project.pbxproj +24 -1
  272. data/res/generators/templates/iphone_project/Classes/SimpleSwiftClass.swift +20 -0
  273. data/res/generators/templates/iphone_project/Classes/rhorunner-Bridging-Header.h +4 -0
  274. data/rhobuild.yml.example +4 -4
  275. data/rhodes.gemspec +4 -3
  276. data/version +1 -1
  277. metadata +157 -57
  278. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/drawable/camera_btn.xml +0 -14
  279. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/layout/camera_land.xml +0 -23
  280. data/lib/commonAPI/mediacapture/ext/platform/android/adds/res/layout/camera_port.xml +0 -23
  281. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraActivity.java +0 -156
  282. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraEclair.java +0 -227
  283. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraGingerbread.java +0 -152
  284. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraPreview.java +0 -183
  285. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonEclair.java +0 -14
  286. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/CameraSingletonGingerbread.java +0 -60
  287. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/ICameraObject.java +0 -20
  288. data/lib/commonAPI/mediacapture/ext/platform/android/src/com/rho/camera/ICameraSingletonObject.java +0 -8
  289. data/lib/extensions/fcm-push/ext/android/src/com/rhomobile/rhodes/fcm/FCMTokenRefresherService.java +0 -27
  290. data/platform/android/Rhodes/AndroidManifest.xml.erb +0 -89
  291. data/platform/sailfish/build/rho_build.cmd.erb +0 -14
  292. data/platform/sailfish/build/rho_clean.cmd.erb +0 -14
  293. data/platform/sailfish/build/rho_deploy.cmd.erb +0 -15
  294. data/platform/sailfish/build/rho_rpm.cmd.erb +0 -14
  295. data/platform/sailfish/build/rho_rpmvalidation.cmd.erb +0 -14
  296. data/platform/sailfish/build/rpm/harbour-SailfishRhodes.desktop.erb +0 -7
  297. data/platform/sailfish/build/rpm/harbour-SailfishRhodes.erb +0 -2
  298. data/platform/sailfish/build/rpm/harbour-SailfishRhodes.yaml.erb +0 -37
  299. data/platform/shared/qt/sailfish/harbour-sailfishrhodes.desktop +0 -6
  300. data/platform/shared/qt/sailfish/icons/108x108/harbour-sailfishrhodes.png +0 -0
  301. data/platform/shared/qt/sailfish/privileges/harbour-sailfishrhodes +0 -2
  302. data/platform/shared/qt/sailfish/qml/pages/FirstPageWE.qml +0 -236
  303. /data/platform/shared/qt/sailfish/icons/128x128/{harbour-sailfishrhodes.png → sailfishrhodes.png} +0 -0
  304. /data/platform/shared/qt/sailfish/icons/172x172/{harbour-sailfishrhodes.png → sailfishrhodes.png} +0 -0
  305. /data/platform/shared/qt/sailfish/icons/86x86/{harbour-sailfishrhodes.png → sailfishrhodes.png} +0 -0
@@ -0,0 +1,292 @@
1
+ #import "HTTPDynamicFileResponse.h"
2
+ #import "HTTPConnection.h"
3
+ #import "HTTPLogging.h"
4
+
5
+ #if ! __has_feature(objc_arc)
6
+ #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
7
+ #endif
8
+
9
+ // Log levels : off, error, warn, info, verbose
10
+ // Other flags: trace
11
+ static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE;
12
+
13
+ #define NULL_FD -1
14
+
15
+
16
+ @implementation HTTPDynamicFileResponse
17
+
18
+ - (id)initWithFilePath:(NSString *)fpath
19
+ forConnection:(HTTPConnection *)parent
20
+ separator:(NSString *)separatorStr
21
+ replacementDictionary:(NSDictionary *)dict
22
+ {
23
+ if ((self = [super initWithFilePath:fpath forConnection:parent]))
24
+ {
25
+ HTTPLogTrace();
26
+
27
+ separator = [separatorStr dataUsingEncoding:NSUTF8StringEncoding];
28
+ replacementDict = dict;
29
+ }
30
+ return self;
31
+ }
32
+
33
+ - (BOOL)isChunked
34
+ {
35
+ HTTPLogTrace();
36
+
37
+ return YES;
38
+ }
39
+
40
+ - (UInt64)contentLength
41
+ {
42
+ // This method shouldn't be called since we're using a chunked response.
43
+ // We override it just to be safe.
44
+
45
+ HTTPLogTrace();
46
+
47
+ return 0;
48
+ }
49
+
50
+ - (void)setOffset:(UInt64)offset
51
+ {
52
+ // This method shouldn't be called since we're using a chunked response.
53
+ // We override it just to be safe.
54
+
55
+ HTTPLogTrace();
56
+ }
57
+
58
+ - (BOOL)isDone
59
+ {
60
+ BOOL result = (readOffset == fileLength) && (readBufferOffset == 0);
61
+
62
+ HTTPLogTrace2(@"%@[%p]: isDone - %@", THIS_FILE, self, (result ? @"YES" : @"NO"));
63
+
64
+ return result;
65
+ }
66
+
67
+ - (void)processReadBuffer
68
+ {
69
+ HTTPLogTrace();
70
+
71
+ // At this point, the readBuffer has readBufferOffset bytes available.
72
+ // This method is in charge of updating the readBufferOffset.
73
+
74
+ NSUInteger bufLen = readBufferOffset;
75
+ NSUInteger sepLen = [separator length];
76
+
77
+ // We're going to start looking for the separator at the beginning of the buffer,
78
+ // and stop when we get to the point where the separator would no longer fit in the buffer.
79
+
80
+ NSUInteger offset = 0;
81
+ NSUInteger stopOffset = (bufLen > sepLen) ? bufLen - sepLen + 1 : 0;
82
+
83
+ // In order to do the replacement, we need to find the starting and ending separator.
84
+ // For example:
85
+ //
86
+ // %%USER_NAME%%
87
+ //
88
+ // Where "%%" is the separator.
89
+
90
+ BOOL found1 = NO;
91
+ BOOL found2 = NO;
92
+
93
+ NSUInteger s1 = 0;
94
+ NSUInteger s2 = 0;
95
+
96
+ const void *sep = [separator bytes];
97
+
98
+ while (offset < stopOffset)
99
+ {
100
+ const void *subBuffer = readBuffer + offset;
101
+
102
+ if (memcmp(subBuffer, sep, sepLen) == 0)
103
+ {
104
+ if (!found1)
105
+ {
106
+ // Found the first separator
107
+
108
+ found1 = YES;
109
+ s1 = offset;
110
+ offset += sepLen;
111
+
112
+ HTTPLogVerbose(@"%@[%p]: Found s1 at %lu", THIS_FILE, self, (unsigned long)s1);
113
+ }
114
+ else
115
+ {
116
+ // Found the second separator
117
+
118
+ found2 = YES;
119
+ s2 = offset;
120
+ offset += sepLen;
121
+
122
+ HTTPLogVerbose(@"%@[%p]: Found s2 at %lu", THIS_FILE, self, (unsigned long)s2);
123
+ }
124
+
125
+ if (found1 && found2)
126
+ {
127
+ // We found our separators.
128
+ // Now extract the string between the two separators.
129
+
130
+ NSRange fullRange = NSMakeRange(s1, (s2 - s1 + sepLen));
131
+ NSRange strRange = NSMakeRange(s1 + sepLen, (s2 - s1 - sepLen));
132
+
133
+ // Wish we could use the simple subdataWithRange method.
134
+ // But that method copies the bytes...
135
+ // So for performance reasons, we need to use the methods that don't copy the bytes.
136
+
137
+ void *strBuf = readBuffer + strRange.location;
138
+ NSUInteger strLen = strRange.length;
139
+
140
+ NSString *key = [[NSString alloc] initWithBytes:strBuf length:strLen encoding:NSUTF8StringEncoding];
141
+ if (key)
142
+ {
143
+ // Is there a given replacement for this key?
144
+
145
+ id value = [replacementDict objectForKey:key];
146
+ if (value)
147
+ {
148
+ // Found the replacement value.
149
+ // Now perform the replacement in the buffer.
150
+
151
+ HTTPLogVerbose(@"%@[%p]: key(%@) -> value(%@)", THIS_FILE, self, key, value);
152
+
153
+ NSData *v = [[value description] dataUsingEncoding:NSUTF8StringEncoding];
154
+ NSUInteger vLength = [v length];
155
+
156
+ if (fullRange.length == vLength)
157
+ {
158
+ // Replacement is exactly the same size as what it is replacing
159
+
160
+ // memcpy(void *restrict dst, const void *restrict src, size_t n);
161
+
162
+ memcpy(readBuffer + fullRange.location, [v bytes], vLength);
163
+ }
164
+ else // (fullRange.length != vLength)
165
+ {
166
+ NSInteger diff = (NSInteger)vLength - (NSInteger)fullRange.length;
167
+
168
+ if (diff > 0)
169
+ {
170
+ // Replacement is bigger than what it is replacing.
171
+ // Make sure there is room in the buffer for the replacement.
172
+
173
+ if (diff > (readBufferSize - bufLen))
174
+ {
175
+ NSUInteger inc = MAX(diff, 256);
176
+
177
+ readBufferSize += inc;
178
+ readBuffer = reallocf(readBuffer, readBufferSize);
179
+ }
180
+ }
181
+
182
+ // Move the data that comes after the replacement.
183
+ //
184
+ // If replacement is smaller than what it is replacing,
185
+ // then we are shifting the data toward the beginning of the buffer.
186
+ //
187
+ // If replacement is bigger than what it is replacing,
188
+ // then we are shifting the data toward the end of the buffer.
189
+ //
190
+ // memmove(void *dst, const void *src, size_t n);
191
+ //
192
+ // The memmove() function copies n bytes from src to dst.
193
+ // The two areas may overlap; the copy is always done in a non-destructive manner.
194
+
195
+ void *src = readBuffer + fullRange.location + fullRange.length;
196
+ void *dst = readBuffer + fullRange.location + vLength;
197
+
198
+ NSUInteger remaining = bufLen - (fullRange.location + fullRange.length);
199
+
200
+ memmove(dst, src, remaining);
201
+
202
+ // Now copy the replacement into its location.
203
+ //
204
+ // memcpy(void *restrict dst, const void *restrict src, size_t n)
205
+ //
206
+ // The memcpy() function copies n bytes from src to dst.
207
+ // If the two areas overlap, behavior is undefined.
208
+
209
+ memcpy(readBuffer + fullRange.location, [v bytes], vLength);
210
+
211
+ // And don't forget to update our indices.
212
+
213
+ bufLen += diff;
214
+ offset += diff;
215
+ stopOffset += diff;
216
+ }
217
+ }
218
+
219
+ }
220
+
221
+ found1 = found2 = NO;
222
+ }
223
+ }
224
+ else
225
+ {
226
+ offset++;
227
+ }
228
+ }
229
+
230
+ // We've gone through our buffer now, and performed all the replacements that we could.
231
+ // It's now time to update the amount of available data we have.
232
+
233
+ if (readOffset == fileLength)
234
+ {
235
+ // We've read in the entire file.
236
+ // So there can be no more replacements.
237
+
238
+ data = [[NSData alloc] initWithBytes:readBuffer length:bufLen];
239
+ readBufferOffset = 0;
240
+ }
241
+ else
242
+ {
243
+ // There are a couple different situations that we need to take into account here.
244
+ //
245
+ // Imagine the following file:
246
+ // My name is %%USER_NAME%%
247
+ //
248
+ // Situation 1:
249
+ // The first chunk of data we read was "My name is %%".
250
+ // So we found the first separator, but not the second.
251
+ // In this case we can only return the data that precedes the first separator.
252
+ //
253
+ // Situation 2:
254
+ // The first chunk of data we read was "My name is %".
255
+ // So we didn't find any separators, but part of a separator may be included in our buffer.
256
+
257
+ NSUInteger available;
258
+ if (found1)
259
+ {
260
+ // Situation 1
261
+ available = s1;
262
+ }
263
+ else
264
+ {
265
+ // Situation 2
266
+ available = stopOffset;
267
+ }
268
+
269
+ // Copy available data
270
+
271
+ data = [[NSData alloc] initWithBytes:readBuffer length:available];
272
+
273
+ // Remove the copied data from the buffer.
274
+ // We do this by shifting the remaining data toward the beginning of the buffer.
275
+
276
+ NSUInteger remaining = bufLen - available;
277
+
278
+ memmove(readBuffer, readBuffer + available, remaining);
279
+ readBufferOffset = remaining;
280
+ }
281
+
282
+ [connection responseHasAvailableData:self];
283
+ }
284
+
285
+ - (void)dealloc
286
+ {
287
+ HTTPLogTrace();
288
+
289
+
290
+ }
291
+
292
+ @end
@@ -0,0 +1,9 @@
1
+ #import "HTTPResponse.h"
2
+
3
+ @interface HTTPErrorResponse : NSObject <HTTPResponse> {
4
+ NSInteger _status;
5
+ }
6
+
7
+ - (id)initWithErrorCode:(int)httpErrorCode;
8
+
9
+ @end
@@ -0,0 +1,38 @@
1
+ #import "HTTPErrorResponse.h"
2
+
3
+ @implementation HTTPErrorResponse
4
+
5
+ -(id)initWithErrorCode:(int)httpErrorCode
6
+ {
7
+ if ((self = [super init]))
8
+ {
9
+ _status = httpErrorCode;
10
+ }
11
+
12
+ return self;
13
+ }
14
+
15
+ - (UInt64) contentLength {
16
+ return 0;
17
+ }
18
+
19
+ - (UInt64) offset {
20
+ return 0;
21
+ }
22
+
23
+ - (void)setOffset:(UInt64)offset {
24
+ ;
25
+ }
26
+
27
+ - (NSData*) readDataOfLength:(NSUInteger)length {
28
+ return nil;
29
+ }
30
+
31
+ - (BOOL) isDone {
32
+ return YES;
33
+ }
34
+
35
+ - (NSInteger) status {
36
+ return _status;
37
+ }
38
+ @end
@@ -0,0 +1,25 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import "HTTPResponse.h"
3
+
4
+ @class HTTPConnection;
5
+
6
+
7
+ @interface HTTPFileResponse : NSObject <HTTPResponse>
8
+ {
9
+ HTTPConnection *connection;
10
+
11
+ NSString *filePath;
12
+ UInt64 fileLength;
13
+ UInt64 fileOffset;
14
+
15
+ BOOL aborted;
16
+
17
+ int fileFD;
18
+ void *buffer;
19
+ NSUInteger bufferSize;
20
+ }
21
+
22
+ - (id)initWithFilePath:(NSString *)filePath forConnection:(HTTPConnection *)connection;
23
+ - (NSString *)filePath;
24
+
25
+ @end
@@ -0,0 +1,237 @@
1
+ #import "HTTPFileResponse.h"
2
+ #import "HTTPConnection.h"
3
+ #import "HTTPLogging.h"
4
+
5
+ #import <unistd.h>
6
+ #import <fcntl.h>
7
+
8
+ #if ! __has_feature(objc_arc)
9
+ #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
10
+ #endif
11
+
12
+ // Log levels : off, error, warn, info, verbose
13
+ // Other flags: trace
14
+ static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE;
15
+
16
+ #define NULL_FD -1
17
+
18
+
19
+ @implementation HTTPFileResponse
20
+
21
+ - (id)initWithFilePath:(NSString *)fpath forConnection:(HTTPConnection *)parent
22
+ {
23
+ if((self = [super init]))
24
+ {
25
+ HTTPLogTrace();
26
+
27
+ connection = parent; // Parents retain children, children do NOT retain parents
28
+
29
+ fileFD = NULL_FD;
30
+ filePath = [[fpath copy] stringByResolvingSymlinksInPath];
31
+ if (filePath == nil)
32
+ {
33
+ HTTPLogWarn(@"%@: Init failed - Nil filePath", THIS_FILE);
34
+
35
+ return nil;
36
+ }
37
+
38
+ NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
39
+ if (fileAttributes == nil)
40
+ {
41
+ HTTPLogWarn(@"%@: Init failed - Unable to get file attributes. filePath: %@", THIS_FILE, filePath);
42
+
43
+ return nil;
44
+ }
45
+
46
+ fileLength = (UInt64)[[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue];
47
+ fileOffset = 0;
48
+
49
+ aborted = NO;
50
+
51
+ // We don't bother opening the file here.
52
+ // If this is a HEAD request we only need to know the fileLength.
53
+ }
54
+ return self;
55
+ }
56
+
57
+ - (void)abort
58
+ {
59
+ HTTPLogTrace();
60
+
61
+ [connection responseDidAbort:self];
62
+ aborted = YES;
63
+ }
64
+
65
+ - (BOOL)openFile
66
+ {
67
+ HTTPLogTrace();
68
+
69
+ fileFD = open([filePath UTF8String], O_RDONLY);
70
+ if (fileFD == NULL_FD)
71
+ {
72
+ HTTPLogError(@"%@[%p]: Unable to open file. filePath: %@", THIS_FILE, self, filePath);
73
+
74
+ [self abort];
75
+ return NO;
76
+ }
77
+
78
+ HTTPLogVerbose(@"%@[%p]: Open fd[%i] -> %@", THIS_FILE, self, fileFD, filePath);
79
+
80
+ return YES;
81
+ }
82
+
83
+ - (BOOL)openFileIfNeeded
84
+ {
85
+ if (aborted)
86
+ {
87
+ // The file operation has been aborted.
88
+ // This could be because we failed to open the file,
89
+ // or the reading process failed.
90
+ return NO;
91
+ }
92
+
93
+ if (fileFD != NULL_FD)
94
+ {
95
+ // File has already been opened.
96
+ return YES;
97
+ }
98
+
99
+ return [self openFile];
100
+ }
101
+
102
+ - (UInt64)contentLength
103
+ {
104
+ HTTPLogTrace();
105
+
106
+ return fileLength;
107
+ }
108
+
109
+ - (UInt64)offset
110
+ {
111
+ HTTPLogTrace();
112
+
113
+ return fileOffset;
114
+ }
115
+
116
+ - (void)setOffset:(UInt64)offset
117
+ {
118
+ HTTPLogTrace2(@"%@[%p]: setOffset:%llu", THIS_FILE, self, offset);
119
+
120
+ if (![self openFileIfNeeded])
121
+ {
122
+ // File opening failed,
123
+ // or response has been aborted due to another error.
124
+ return;
125
+ }
126
+
127
+ fileOffset = offset;
128
+
129
+ off_t result = lseek(fileFD, (off_t)offset, SEEK_SET);
130
+ if (result == -1)
131
+ {
132
+ HTTPLogError(@"%@[%p]: lseek failed - errno(%i) filePath(%@)", THIS_FILE, self, errno, filePath);
133
+
134
+ [self abort];
135
+ }
136
+ }
137
+
138
+ - (NSData *)readDataOfLength:(NSUInteger)length
139
+ {
140
+ HTTPLogTrace2(@"%@[%p]: readDataOfLength:%lu", THIS_FILE, self, (unsigned long)length);
141
+
142
+ if (![self openFileIfNeeded])
143
+ {
144
+ // File opening failed,
145
+ // or response has been aborted due to another error.
146
+ return nil;
147
+ }
148
+
149
+ // Determine how much data we should read.
150
+ //
151
+ // It is OK if we ask to read more bytes than exist in the file.
152
+ // It is NOT OK to over-allocate the buffer.
153
+
154
+ UInt64 bytesLeftInFile = fileLength - fileOffset;
155
+
156
+ NSUInteger bytesToRead = (NSUInteger)MIN(length, bytesLeftInFile);
157
+
158
+ // Make sure buffer is big enough for read request.
159
+ // Do not over-allocate.
160
+
161
+ if (buffer == NULL || bufferSize < bytesToRead)
162
+ {
163
+ bufferSize = bytesToRead;
164
+ buffer = reallocf(buffer, (size_t)bufferSize);
165
+
166
+ if (buffer == NULL)
167
+ {
168
+ HTTPLogError(@"%@[%p]: Unable to allocate buffer", THIS_FILE, self);
169
+
170
+ [self abort];
171
+ return nil;
172
+ }
173
+ }
174
+
175
+ // Perform the read
176
+
177
+ HTTPLogVerbose(@"%@[%p]: Attempting to read %lu bytes from file", THIS_FILE, self, (unsigned long)bytesToRead);
178
+
179
+ ssize_t result = read(fileFD, buffer, bytesToRead);
180
+
181
+ // Check the results
182
+
183
+ if (result < 0)
184
+ {
185
+ HTTPLogError(@"%@: Error(%i) reading file(%@)", THIS_FILE, errno, filePath);
186
+
187
+ [self abort];
188
+ return nil;
189
+ }
190
+ else if (result == 0)
191
+ {
192
+ HTTPLogError(@"%@: Read EOF on file(%@)", THIS_FILE, filePath);
193
+
194
+ [self abort];
195
+ return nil;
196
+ }
197
+ else // (result > 0)
198
+ {
199
+ HTTPLogVerbose(@"%@[%p]: Read %ld bytes from file", THIS_FILE, self, (long)result);
200
+
201
+ fileOffset += result;
202
+
203
+ return [NSData dataWithBytes:buffer length:result];
204
+ }
205
+ }
206
+
207
+ - (BOOL)isDone
208
+ {
209
+ BOOL result = (fileOffset == fileLength);
210
+
211
+ HTTPLogTrace2(@"%@[%p]: isDone - %@", THIS_FILE, self, (result ? @"YES" : @"NO"));
212
+
213
+ return result;
214
+ }
215
+
216
+ - (NSString *)filePath
217
+ {
218
+ return filePath;
219
+ }
220
+
221
+ - (void)dealloc
222
+ {
223
+ HTTPLogTrace();
224
+
225
+ if (fileFD != NULL_FD)
226
+ {
227
+ HTTPLogVerbose(@"%@[%p]: Close fd[%i]", THIS_FILE, self, fileFD);
228
+
229
+ close(fileFD);
230
+ }
231
+
232
+ if (buffer)
233
+ free(buffer);
234
+
235
+ }
236
+
237
+ @end
@@ -0,0 +1,12 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import "HTTPResponse.h"
3
+
4
+
5
+ @interface HTTPRedirectResponse : NSObject <HTTPResponse>
6
+ {
7
+ NSString *redirectPath;
8
+ }
9
+
10
+ - (id)initWithPath:(NSString *)redirectPath;
11
+
12
+ @end
@@ -0,0 +1,73 @@
1
+ #import "HTTPRedirectResponse.h"
2
+ #import "HTTPLogging.h"
3
+
4
+ #if ! __has_feature(objc_arc)
5
+ #warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
6
+ #endif
7
+
8
+ // Log levels : off, error, warn, info, verbose
9
+ // Other flags: trace
10
+ static const int httpLogLevel = HTTP_LOG_LEVEL_OFF; // | HTTP_LOG_FLAG_TRACE;
11
+
12
+
13
+ @implementation HTTPRedirectResponse
14
+
15
+ - (id)initWithPath:(NSString *)path
16
+ {
17
+ if ((self = [super init]))
18
+ {
19
+ HTTPLogTrace();
20
+
21
+ redirectPath = [path copy];
22
+ }
23
+ return self;
24
+ }
25
+
26
+ - (UInt64)contentLength
27
+ {
28
+ return 0;
29
+ }
30
+
31
+ - (UInt64)offset
32
+ {
33
+ return 0;
34
+ }
35
+
36
+ - (void)setOffset:(UInt64)offset
37
+ {
38
+ // Nothing to do
39
+ }
40
+
41
+ - (NSData *)readDataOfLength:(NSUInteger)length
42
+ {
43
+ HTTPLogTrace();
44
+
45
+ return nil;
46
+ }
47
+
48
+ - (BOOL)isDone
49
+ {
50
+ return YES;
51
+ }
52
+
53
+ - (NSDictionary *)httpHeaders
54
+ {
55
+ HTTPLogTrace();
56
+
57
+ return [NSDictionary dictionaryWithObject:redirectPath forKey:@"Location"];
58
+ }
59
+
60
+ - (NSInteger)status
61
+ {
62
+ HTTPLogTrace();
63
+
64
+ return 302;
65
+ }
66
+
67
+ - (void)dealloc
68
+ {
69
+ HTTPLogTrace();
70
+
71
+ }
72
+
73
+ @end