rhodes 2.2.6 → 2.3.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +20 -0
- data/README.md +46 -0
- data/Rakefile +85 -80
- data/bin/rhodes +2 -2
- data/bin/rhogen +1 -1
- data/doc/application.txt +277 -0
- data/doc/bb-css.txt +209 -0
- data/doc/build.txt +785 -0
- data/doc/configuration.txt +236 -0
- data/doc/connect-to-web-services.txt +282 -0
- data/doc/contributing.txt +64 -0
- data/doc/css-framework.txt +144 -0
- data/doc/device-caps.txt +1152 -0
- data/doc/extensions.txt +528 -0
- data/doc/files.txt +4 -0
- data/doc/generator.txt +141 -0
- data/doc/install.txt +35 -0
- data/doc/introduction.txt +88 -0
- data/doc/rhom.txt +826 -0
- data/doc/standard-css.txt +392 -0
- data/doc/synchronization.txt +542 -0
- data/doc/test-log-debug.txt +148 -0
- data/doc/tutorial.txt +136 -0
- data/doc/ui.txt +766 -0
- data/installer/EnvVarUpdate.nsh +328 -0
- data/installer/README.html +81 -0
- data/installer/RHOSYNC-LICENSE.txt +675 -0
- data/installer/icon.ico +0 -0
- data/installer/instant-rhodes.nsi +427 -0
- data/lib/build/jake.rb +15 -1
- data/lib/extensions/barcode/ext/barcode/platform/android/jni/src/imageprovider.cpp +1 -1
- data/lib/extensions/barcode/ext/barcode/platform/bb/Barcode6.files +45 -0
- data/lib/extensions/barcode/ext/barcode/platform/bb/Rakefile +6 -0
- data/lib/extensions/barcode/ext/barcode/platform/bb/barcode6.jdp +92 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +7 -4
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Rakefile +2 -1
- data/lib/extensions/barcode/ext/barcode/platform/wm/src/wm_imageprovider.cpp +1 -1
- data/lib/extensions/digest-sha1/ext/build.bat +1 -0
- data/lib/extensions/digest-sha1/ext/digest-sha1.vcproj +335 -0
- data/lib/extensions/esri/ext/build +17 -0
- data/lib/extensions/esri/ext/build.bat +29 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactory.h +7 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactory.mm +58 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewFactoryRegister.mm +22 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewManager.h +21 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/ESRIViewManager.mm +32 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/InitESRI.c +5 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/MapViewControllerESRI.h +143 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Classes/MapViewControllerESRI.m +919 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/ESRI.xcodeproj/project.pbxproj +320 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/ESRI_Prefix.pch +7 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/Rakefile +76 -0
- data/lib/extensions/esri/ext.yml +3 -0
- data/lib/extensions/net-http/monitor.rb +265 -0
- data/lib/extensions/net-http/net/ftp.rb +981 -0
- data/lib/extensions/net-http/thread.rb +367 -0
- data/lib/extensions/rhocgi/cgi.rb +16 -0
- data/lib/extensions/rhospec/rhospec.rb +118 -0
- data/lib/framework/base64.rb +91 -0
- data/lib/framework/builtinME.rb +13 -10
- data/lib/framework/ostruct.rb +145 -0
- data/lib/framework/res/back_btn.wm.png +0 -0
- data/lib/framework/res/blue_pushpin.wm.png +0 -0
- data/lib/framework/res/blue_pushpin_small.wm.png +0 -0
- data/lib/framework/res/callout.wm.png +0 -0
- data/lib/framework/res/callout_link.wm.png +0 -0
- data/lib/framework/res/forward_btn.wm.png +0 -0
- data/lib/framework/res/home_btn.wm.png +0 -0
- data/lib/framework/res/options_btn.wm.png +0 -0
- data/lib/framework/res/refresh_btn.wm.png +0 -0
- data/lib/framework/rho/render.rb +5 -2
- data/lib/framework/rho/rho.rb +320 -50
- data/lib/framework/rho/rhoapplication.rb +48 -10
- data/lib/framework/rho/rhonativeviewmanager.rb +73 -0
- data/lib/framework/rho/rhosupport.rb +15 -1
- data/lib/framework/rho/rhotabbar.rb +29 -0
- data/lib/framework/rho/rhotoolbar.rb +17 -0
- data/lib/framework/rho/rhoutils.rb +22 -6
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rholang/rhomsg_de.rb +4 -3
- data/lib/framework/rholang/rhomsg_en.rb +1 -0
- data/lib/framework/rholang/rhomsg_es.rb +1 -0
- data/lib/framework/rholang/rhomsg_it.rb +1 -0
- data/lib/framework/rhom/rhom.rb +31 -10
- data/lib/framework/rhom/rhom_db_adapter.rb +33 -23
- data/lib/framework/rhom/rhom_object_factory.rb +465 -249
- data/lib/framework/rhom/rhom_source.rb +22 -7
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/AndroidManifest.xml +83 -20
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +5 -0
- data/platform/android/Rhodes/jni/include/rhodes/RhoClassFactory.h +2 -0
- data/platform/android/Rhodes/jni/include/rhodes/details/rhojava.inc +9 -5
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesAppOptions.h +53 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +46 -56
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_SplashScreen.h +10 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_mapview_MapView.h +93 -0
- data/platform/android/Rhodes/jni/include/rhodes/rhocryptimpl.h +38 -0
- data/platform/android/Rhodes/jni/include/rhodes.h +64 -8
- data/platform/android/Rhodes/jni/src/RhoClassFactory.cpp +6 -0
- data/platform/android/Rhodes/jni/src/alert.cpp +5 -11
- data/platform/android/Rhodes/jni/src/bluetooth.cpp +66 -29
- data/platform/android/Rhodes/jni/src/callbacks.cpp +24 -21
- data/platform/android/Rhodes/jni/src/camera.cpp +2 -6
- data/platform/android/Rhodes/jni/src/datetimepicker.cpp +13 -11
- data/platform/android/Rhodes/jni/src/event.cpp +9 -15
- data/platform/android/Rhodes/jni/src/fileapi.cpp +13 -27
- data/platform/android/Rhodes/jni/src/logconf.cpp +3 -3
- data/platform/android/Rhodes/jni/src/mapview.cpp +696 -16
- data/platform/android/Rhodes/jni/src/menu.cpp +3 -3
- data/platform/android/Rhodes/jni/src/nativebar.cpp +55 -4
- data/platform/android/Rhodes/jni/src/nativeview.cpp +33 -0
- data/platform/android/Rhodes/jni/src/phonebook.cpp +6 -11
- data/platform/android/Rhodes/jni/src/rhoconf.cpp +4 -4
- data/platform/android/Rhodes/jni/src/rhocryptimpl.cpp +87 -0
- data/platform/android/Rhodes/jni/src/rhodes.cpp +55 -34
- data/platform/android/Rhodes/jni/src/ringtones.cpp +2 -3
- data/platform/android/Rhodes/jni/src/signature.cpp +3 -5
- data/platform/android/Rhodes/jni/src/splashscreen.cpp +7 -0
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +17 -20
- data/platform/android/Rhodes/jni/src/webview.cpp +13 -12
- data/platform/android/Rhodes/res/drawable/callout.png +0 -0
- data/platform/android/Rhodes/res/drawable/callout_link.png +0 -0
- data/platform/android/Rhodes/res/drawable/signature_cancel.png +0 -0
- data/platform/android/Rhodes/res/drawable/signature_clear.png +0 -0
- data/platform/android/Rhodes/res/drawable/signature_ok.png +0 -0
- data/platform/android/Rhodes/res/layout/datetime.xml +4 -0
- data/platform/android/Rhodes/res/layout/signature.xml +24 -17
- data/platform/android/Rhodes/res/layout/status_bar_ongoing_event_progress_bar.xml +102 -0
- data/platform/android/Rhodes/res/values/strings.xml +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +6 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Base64.java +575 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +83 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +21 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +23 -15
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +151 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +372 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesAppOptions.java +11 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +58 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +705 -523
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RingtoneManager.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +167 -85
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Utils.java +36 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +4 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +33 -20
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/IRhoBluetoothManager.java +2 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManager.java +2 -24
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerNew.java +106 -36
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerOld.java +15 -58
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothSession.java +0 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +6 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/FileList.java +4 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +91 -27
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePicker.java +6 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +275 -42
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +1 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +1 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +120 -43
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +518 -28
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/AnnotationsOverlay.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/GoogleMapView.java +434 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapTouch.java +20 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +296 -336
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MultiTouchHandler.java +111 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/OneTouchHandler.java +77 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/TouchHandler.java +10 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +0 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +5 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/ImageCapture.java +6 -11
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/Signature.java +6 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +0 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/ui/LogViewDialog.java +9 -4
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +8 -8
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java +5 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientOld.java +11 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +3 -5
- data/platform/android/build/RhodesSRC_build.files +32 -23
- data/platform/android/build/android.rake +28 -11
- data/platform/android/build/androidcommon.rb +2 -0
- data/platform/android/build/librhocommon_build.files +9 -5
- data/platform/android/build/librhodes_build.files +1 -0
- data/platform/android/build/libruby_build.files +1 -0
- data/platform/bb/Hsqldb/Hsqldb.jdp +0 -2
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +10 -2
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +37 -5
- data/platform/bb/Hsqldb/src/org/hsqldb/Column.java +5 -5
- data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Function.java +73 -78
- data/platform/bb/Hsqldb/src/org/hsqldb/Library.java +288 -8
- data/platform/bb/RubyVM/RubyVM.jdp +3 -0
- data/platform/bb/RubyVM/src/com/rho/FilePath.java +13 -1
- data/platform/bb/RubyVM/src/com/rho/IRhoRubyHelper.java +2 -2
- data/platform/bb/RubyVM/src/com/rho/RhoAppAdapter.java +12 -0
- data/platform/bb/RubyVM/src/com/rho/RhoClassFactory.java +18 -1
- data/platform/bb/RubyVM/src/com/rho/RhoConf.java +128 -108
- data/platform/bb/RubyVM/src/com/rho/RhoLogConf.java +9 -10
- data/platform/bb/RubyVM/src/com/rho/RhoLogger.java +16 -1
- data/platform/bb/RubyVM/src/com/rho/RhoProfiler.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +20 -0
- data/platform/bb/RubyVM/src/com/rho/RhodesApp.java +5 -2
- data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +65 -46
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +192 -50
- data/platform/bb/RubyVM/src/com/rho/db/DBAttrManager.java +8 -114
- data/platform/bb/RubyVM/src/com/rho/db/DBException.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/db/IDBCallback.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/db/IDBResult.java +5 -3
- data/platform/bb/RubyVM/src/com/rho/db/IDBStorage.java +5 -1
- data/platform/bb/RubyVM/src/com/rho/file/FileAccessBB.java +109 -0
- data/platform/bb/RubyVM/src/com/rho/file/RhoFile.java +85 -0
- data/platform/bb/RubyVM/src/com/rho/net/NetRequest.java +12 -4
- data/platform/bb/RubyVM/src/com/rho/net/NetResponse.java +5 -0
- data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +37 -23
- data/platform/bb/RubyVM/src/com/rho/net/URI.java +84 -0
- data/platform/bb/RubyVM/src/com/rho/sync/ClientRegister.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +119 -61
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +61 -24
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +108 -54
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +121 -163
- data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyString_Methods.java +23 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyMutex.java +1 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyRange.java +3 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyRegexp.java +3 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyString.java +208 -25
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyTime.java +3 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RhoSupport.java +5 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyAPI.java +12 -5
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyID.java +1 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule.java +16 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule_Methods.java +5 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyValue.java +1 -1
- data/platform/bb/RubyVM/src/com/xruby/runtime/stdlib/RubyStringIO.java +4 -1
- data/platform/bb/{Hsqldb → RubyVM}/src/j2me/math/Number.java +33 -0
- data/platform/bb/build/RubyVM_build.files +3 -0
- data/platform/bb/build/bb.rake +140 -62
- data/platform/bb/build/hsqldb_build.files +0 -2
- data/platform/bb/build/rhodes_build.files +5 -0
- data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +43 -7
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +23 -2
- data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +5 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteCopyResult.java +143 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteResult.java +269 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/db/SqliteStorage.java +446 -0
- data/platform/bb/rhodes/platform/common/com/rho/BrowserAdapter5.java +3 -0
- data/platform/bb/rhodes/platform/common/com/rho/RhoMainScreen.java +12 -2
- data/platform/bb/rhodes/platform/common/com/rho/db/SqliteCopyResult.java +2 -0
- data/platform/bb/rhodes/platform/common/com/rho/db/SqliteResult.java +2 -0
- data/platform/bb/rhodes/platform/common/com/rho/db/SqliteStorage.java +2 -0
- data/platform/bb/rhodes/resources/mappin.png +0 -0
- data/platform/bb/rhodes/rhodes.jdp +3 -0
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +21 -18
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter5.java +150 -0
- data/platform/bb/rhodes/src/com/rho/IBrowserAdapter.java +1 -0
- data/platform/bb/rhodes/src/com/rho/RhoMainScreen.java +63 -4
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +6 -5
- data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +242 -2
- data/platform/bb/rhodes/src/com/rho/db/SqliteCopyResult.java +143 -0
- data/platform/bb/rhodes/src/com/rho/db/SqliteResult.java +269 -0
- data/platform/bb/rhodes/src/com/rho/db/SqliteStorage.java +446 -0
- data/platform/bb/rhodes/src/com/rho/file/Jsr75File.java +1 -1
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +71 -14
- data/platform/bb/rhodes/src/com/rho/net/bb/BBHttpConnection.java +4 -2
- data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +28 -12
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +100 -4
- data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +3 -2
- data/platform/bb/rhodes/src/com/rho/rubyext/XMLParser.java +1 -1
- data/platform/bb/rhodes/src/rhomobile/NativeBar.java +32 -0
- data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +9 -2
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +174 -41
- data/platform/bb/rhodes/src/rhomobile/datetime/DateTimePicker.java +52 -3
- data/platform/bb/rhodes/src/rhomobile/datetime/DateTimeScreen.java +33 -1
- data/platform/bb/rhodes/src/rhomobile/mapview/Annotation.java +2 -14
- data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapField.java +686 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapProvider.java +14 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/GeoCoding.java +13 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/GoogleGeoCoding.java +174 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/GoogleMapField.java +104 -330
- data/platform/bb/rhodes/src/rhomobile/mapview/MapTools.java +79 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/MapView.java +35 -12
- data/platform/bb/rhodes/src/rhomobile/mapview/MapViewParent.java +2 -1
- data/platform/bb/rhodes/src/rhomobile/mapview/MapViewScreen.java +336 -44
- data/platform/bb/rhodes/src/rhomobile/mapview/RhoMapField.java +3 -6
- data/platform/iphone/Classes/AppManager/AppManager.m +19 -4
- data/platform/iphone/Classes/DateTime.h +4 -0
- data/platform/iphone/Classes/DateTime.m +1 -1
- data/platform/iphone/Classes/DateTimePicker.m +8 -1
- data/platform/iphone/Classes/DateTimePickerDelegate.m +7 -1
- data/platform/iphone/Classes/Event/Event.m +2 -2
- data/platform/iphone/Classes/MapView/MapViewController.h +4 -1
- data/platform/iphone/Classes/MapView/MapViewController.m +6 -46
- data/platform/iphone/Classes/MapView/MapViewManager.h +26 -0
- data/platform/iphone/Classes/MapView/MapViewManager.m +172 -0
- data/platform/iphone/Classes/NativeBar.h +34 -0
- data/platform/iphone/Classes/NativeBar.m +131 -26
- data/platform/iphone/Classes/NativeView/NVDelegate.h +26 -0
- data/platform/iphone/Classes/NativeView/NVDelegate.m +40 -0
- data/platform/iphone/Classes/NativeView/NVViewController.h +24 -0
- data/platform/iphone/Classes/NativeView/NVViewController.m +90 -0
- data/platform/iphone/Classes/NativeView/RhoNativeViewManager.mm +449 -0
- data/platform/iphone/Classes/{RhoNativeViewManagerOC.h → NativeView/RhoNativeViewManagerOC.h} +15 -0
- data/platform/iphone/Classes/RhoAlert.m +3 -3
- data/platform/iphone/Classes/RhoMainView.h +3 -0
- data/platform/iphone/Classes/Rhodes.h +6 -2
- data/platform/iphone/Classes/Rhodes.m +47 -79
- data/platform/iphone/Classes/Signature/SignatureViewController.m +1 -0
- data/platform/iphone/Classes/SimpleMainView.h +18 -1
- data/platform/iphone/Classes/SimpleMainView.m +180 -35
- data/platform/iphone/Classes/SplitView/LeftViewController.h +1 -1
- data/platform/iphone/Classes/SplitView/LeftViewController.m +13 -7
- data/platform/iphone/Classes/SplitView/RightViewController.h +1 -1
- data/platform/iphone/Classes/SplitView/RightViewController.m +26 -11
- data/platform/iphone/Classes/SplitView/SplittedMainView.h +1 -6
- data/platform/iphone/Classes/SplitView/SplittedMainView.m +14 -52
- data/platform/iphone/Classes/TabbedMainView.h +25 -3
- data/platform/iphone/Classes/TabbedMainView.m +340 -14
- data/platform/iphone/ESRI/BluePushpin.png +0 -0
- data/platform/iphone/ESRI/BluePushpin@2x.png +0 -0
- data/platform/iphone/ESRI/esri.png +0 -0
- data/platform/iphone/ESRI/esri@2x.png +0 -0
- data/platform/iphone/Info.plist +1 -1
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +26 -3
- data/platform/iphone/rbuild/iphone.rake +100 -4
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +12 -0
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +116 -12
- data/platform/shared/SyncClient/SyncClient.cpp +29 -3
- data/platform/shared/SyncClient/SyncClient.h +2 -1
- data/platform/shared/common/IRhoClassFactory.h +3 -0
- data/platform/shared/common/IRhoCrypt.h +16 -0
- data/platform/shared/common/IRhoThreadImpl.h +1 -0
- data/platform/shared/common/RhoAppAdapter.h +2 -0
- data/platform/shared/common/RhoConf.cpp +97 -46
- data/platform/shared/common/RhoConf.h +14 -13
- data/platform/shared/common/RhoFile.cpp +10 -0
- data/platform/shared/common/RhoFile.h +1 -0
- data/platform/shared/common/RhoMath.cpp +43 -0
- data/platform/shared/common/RhoMath.h +27 -0
- data/platform/shared/common/RhoNativeViewManager.h +27 -1
- data/platform/shared/common/RhoPort.h +11 -0
- data/platform/shared/common/RhoStd.h +5 -0
- data/platform/shared/common/RhoThread.cpp +1 -1
- data/platform/shared/common/RhoThread.h +1 -1
- data/platform/shared/common/RhodesApp.cpp +381 -139
- data/platform/shared/common/RhodesApp.h +24 -10
- data/platform/shared/common/RhodesAppBase.cpp +72 -1
- data/platform/shared/common/RhodesAppBase.h +5 -1
- data/platform/shared/common/SplashScreen.h +4 -4
- data/platform/shared/common/ThreadQueue.cpp +44 -17
- data/platform/shared/common/ThreadQueue.h +4 -0
- data/platform/shared/common/app_build_configs.c +0 -1
- data/platform/shared/common/iphone/RhoClassfactory.h +6 -0
- data/platform/shared/common/iphone/RhoCryptImpl.h +47 -0
- data/platform/shared/common/iphone/RhoCryptImpl.mm +286 -0
- data/platform/shared/common/map/ESRIMapEngine.cpp +921 -0
- data/platform/shared/common/map/ESRIMapEngine.h +255 -0
- data/platform/shared/common/map/GoogleMapEngine.cpp +160 -0
- data/platform/shared/common/map/GoogleMapEngine.h +52 -0
- data/platform/shared/common/map/MapEngine.cpp +304 -0
- data/platform/shared/common/map/MapEngine.h +214 -0
- data/platform/shared/db/DBAdapter.cpp +147 -18
- data/platform/shared/db/DBAdapter.h +38 -12
- data/platform/shared/db/DBAttrManager.cpp +4 -3
- data/platform/shared/db/DBAttrManager.h +7 -7
- data/platform/shared/db/res/db/syncdb.triggers +0 -5
- data/platform/shared/db/res/db/syncdb_java.triggers +21 -0
- data/platform/shared/json/JSONIterator.cpp +11 -1
- data/platform/shared/json/JSONIterator.h +1 -0
- data/platform/shared/logging/RhoLogConf.cpp +29 -12
- data/platform/shared/net/CURLNetRequest.cpp +80 -25
- data/platform/shared/net/CURLNetRequest.h +6 -2
- data/platform/shared/net/HttpServer.cpp +12 -6
- data/platform/shared/net/HttpServer.h +2 -1
- data/platform/shared/net/INetRequest.h +1 -0
- data/platform/shared/ruby/ext/alert/alert.i +5 -0
- data/platform/shared/ruby/ext/alert/alert_wrap.c +439 -108
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker.i +42 -0
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +521 -120
- data/platform/shared/ruby/ext/nativebar/nativebar.i +16 -0
- data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +623 -128
- data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager.i +18 -0
- data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager_wrap.c +2321 -0
- data/platform/shared/ruby/ext/rho/extensions.c +0 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +53 -0
- data/platform/shared/ruby/ext/rho/rhoruby.h +6 -0
- data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +6 -3
- data/platform/shared/ruby/ext/syncengine/syncengine.i +9 -1
- data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +61 -0
- data/platform/shared/ruby/ext/system/system.i +4 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +33 -5
- data/platform/shared/rubyext/RhoAppAdapter.cpp +11 -1
- data/platform/shared/rubyext/System.cpp +9 -0
- data/platform/shared/rubyext/WebView.h +1 -0
- data/platform/shared/sqlite/crypto.c +907 -0
- data/platform/shared/sqlite/sqlite3.c +6 -0
- data/platform/shared/sync/SyncEngine.cpp +49 -19
- data/platform/shared/sync/SyncEngine.h +0 -1
- data/platform/shared/sync/SyncNotify.cpp +14 -5
- data/platform/shared/sync/SyncNotify.h +2 -2
- data/platform/shared/sync/SyncSource.cpp +79 -33
- data/platform/shared/sync/SyncSource.h +1 -0
- data/platform/shared/sync/SyncThread.cpp +26 -11
- data/platform/shared/xruby/src/com/xruby/compiler/codedom/StringExpression.java +4 -2
- data/platform/wm/RhoLib/RhoLib.vcproj +108 -72
- data/platform/wm/build/wm.rake +6 -0
- data/platform/wm/rhodes/Alert.cpp +4 -3
- data/platform/wm/rhodes/Alert.h +1 -1
- data/platform/wm/rhodes/DateTimePicker.cpp +30 -3
- data/platform/wm/rhodes/DateTimePicker.h +9 -1
- data/platform/wm/rhodes/MainWindow.cpp +121 -61
- data/platform/wm/rhodes/MainWindow.h +29 -4
- data/platform/wm/rhodes/MapView/Graphics.cpp +547 -0
- data/platform/wm/rhodes/MapView/Graphics.h +136 -0
- data/platform/wm/rhodes/MapView/MapViewManager.cpp +391 -0
- data/platform/wm/rhodes/MapView/MapViewManager.h +158 -0
- data/platform/wm/rhodes/RhoCryptImpl.cpp +248 -0
- data/platform/wm/rhodes/RhoCryptImpl.h +51 -0
- data/platform/wm/rhodes/RhoNativeViewManager.cpp +208 -0
- data/platform/wm/rhodes/Rhodes.cpp +94 -102
- data/platform/wm/rhodes/Rhodes.rc +27 -0
- data/platform/wm/rhodes/SyncStatusDlg.cpp +1 -0
- data/platform/wm/rhodes/SyncStatusDlg.h +2 -1
- data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +7 -4
- data/platform/wm/rhodes/camera/Camera.cpp +36 -15
- data/platform/wm/rhodes/camera/Camera.h +0 -4
- data/platform/wm/rhodes/resource.h +10 -2
- data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +7 -0
- data/platform/wm/rhodes/rho/common/RhoClassFactory.h +1 -0
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +10 -2
- data/platform/wm/rhodes/rho/net/NetRequestImpl.h +10 -0
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +513 -0
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.h +74 -0
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +22 -10
- data/platform/wm/rhodes/rho/rubyext/WebView.cpp +5 -0
- data/platform/wm/rhodes/rhodes.vcproj +38 -2
- data/platform/wm/rhodes/stdafx.h +2 -1
- data/platform/wm/rubylib/rubylib.vcproj +12 -0
- data/rakefile.rb +85 -80
- data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +14 -3
- data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
- data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +2 -0
- data/res/build-tools/xruby-0.3.3.jar +0 -0
- data/res/generators/templates/application/app/application.rb +2 -2
- data/res/generators/templates/application/app/helpers/application_helper.rb +1 -1
- data/res/generators/templates/application/public/css/android.css +1 -0
- data/res/generators/templates/application/public/jqtouch/jquery.1.3.2.min.js +1 -1
- data/res/generators/templates/application/rhoconfig.txt +66 -14
- data/rhodes.gemspec +3 -3
- data/spec/framework_spec/app/spec/core/file/expand_path_spec.rb +7 -3
- data/spec/framework_spec/build.yml +1 -1
- data/spec/phone_spec/Rakefile +1 -0
- data/spec/phone_spec/app/Account/account.rb +2 -0
- data/spec/phone_spec/app/Account_s/account_s.rb +7 -0
- data/spec/phone_spec/app/spec/{fixtures → array/fixtures}/classes.rb +0 -0
- data/spec/phone_spec/app/spec/{array_pack_spec.rb → array/pack_spec.rb} +2 -1
- data/spec/phone_spec/app/spec/bulksync_spec.rb +1 -0
- data/spec/phone_spec/app/spec/contacts_spec.rb +2 -0
- data/spec/phone_spec/app/spec/rho_spec.rb +34 -233
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +396 -87
- data/spec/phone_spec/app/spec/string/element_set_spec.rb +251 -0
- data/spec/phone_spec/app/spec/string/end_with_spec.rb +49 -0
- data/spec/phone_spec/app/spec/string/fixtures/classes.rb +27 -0
- data/spec/phone_spec/app/spec/{lstrip_spec.rb → string/lstrip_spec.rb} +0 -0
- data/spec/phone_spec/app/spec/string/replace_spec.rb +52 -0
- data/spec/phone_spec/app/spec/{rstrip_spec.rb → string/rstrip_spec.rb} +0 -0
- data/spec/phone_spec/app/spec/string/slice_spec.rb +473 -0
- data/spec/phone_spec/app/spec/string/split_spec.rb +302 -0
- data/spec/phone_spec/app/spec/string/start_with_spec.rb +48 -0
- data/spec/phone_spec/app/spec/{strip_spec.rb → string/strip_spec.rb} +0 -0
- data/spec/phone_spec/app/spec/syncengine_spec.rb +30 -1
- data/spec/phone_spec/app/spec_runner.rb +15 -7
- data/spec/phone_spec/build.yml +2 -2
- metadata +154 -25
- data/README.textile +0 -45
- data/platform/android/Rhodes/AndroidManifest.full.xml +0 -62
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/Manifest.java +0 -14
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoActivity.java +0 -20
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +0 -193
- data/platform/bb/Hsqldb/src/com/rho/file/FileAccessBB.java +0 -25
- data/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java +0 -22
- data/platform/bb/RubyVM/src/com/rho/Capabilities.java +0 -6
- data/platform/bb/RubyVM/src/com/rho/Extensions.java +0 -11
- data/platform/iphone/Classes/RhoNativeViewManager.mm +0 -226
@@ -0,0 +1,981 @@
|
|
1
|
+
#
|
2
|
+
# = net/ftp.rb - FTP Client Library
|
3
|
+
#
|
4
|
+
# Written by Shugo Maeda <shugo@ruby-lang.org>.
|
5
|
+
#
|
6
|
+
# Documentation by Gavin Sinclair, sourced from "Programming Ruby" (Hunt/Thomas)
|
7
|
+
# and "Ruby In a Nutshell" (Matsumoto), used with permission.
|
8
|
+
#
|
9
|
+
# This library is distributed under the terms of the Ruby license.
|
10
|
+
# You can freely distribute/modify this library.
|
11
|
+
#
|
12
|
+
# It is included in the Ruby standard library.
|
13
|
+
#
|
14
|
+
# See the Net::FTP class for an overview.
|
15
|
+
#
|
16
|
+
|
17
|
+
require "socket"
|
18
|
+
require "monitor"
|
19
|
+
|
20
|
+
module Net
|
21
|
+
|
22
|
+
# :stopdoc:
|
23
|
+
class FTPError < StandardError; end
|
24
|
+
class FTPReplyError < FTPError; end
|
25
|
+
class FTPTempError < FTPError; end
|
26
|
+
class FTPPermError < FTPError; end
|
27
|
+
class FTPProtoError < FTPError; end
|
28
|
+
# :startdoc:
|
29
|
+
|
30
|
+
#
|
31
|
+
# This class implements the File Transfer Protocol. If you have used a
|
32
|
+
# command-line FTP program, and are familiar with the commands, you will be
|
33
|
+
# able to use this class easily. Some extra features are included to take
|
34
|
+
# advantage of Ruby's style and strengths.
|
35
|
+
#
|
36
|
+
# == Example
|
37
|
+
#
|
38
|
+
# require 'net/ftp'
|
39
|
+
#
|
40
|
+
# === Example 1
|
41
|
+
#
|
42
|
+
# ftp = Net::FTP.new('ftp.netlab.co.jp')
|
43
|
+
# ftp.login
|
44
|
+
# files = ftp.chdir('pub/lang/ruby/contrib')
|
45
|
+
# files = ftp.list('n*')
|
46
|
+
# ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
|
47
|
+
# ftp.close
|
48
|
+
#
|
49
|
+
# === Example 2
|
50
|
+
#
|
51
|
+
# Net::FTP.open('ftp.netlab.co.jp') do |ftp|
|
52
|
+
# ftp.login
|
53
|
+
# files = ftp.chdir('pub/lang/ruby/contrib')
|
54
|
+
# files = ftp.list('n*')
|
55
|
+
# ftp.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# == Major Methods
|
59
|
+
#
|
60
|
+
# The following are the methods most likely to be useful to users:
|
61
|
+
# - FTP.open
|
62
|
+
# - #getbinaryfile
|
63
|
+
# - #gettextfile
|
64
|
+
# - #putbinaryfile
|
65
|
+
# - #puttextfile
|
66
|
+
# - #chdir
|
67
|
+
# - #nlst
|
68
|
+
# - #size
|
69
|
+
# - #rename
|
70
|
+
# - #delete
|
71
|
+
#
|
72
|
+
class FTP
|
73
|
+
include MonitorMixin
|
74
|
+
|
75
|
+
# :stopdoc:
|
76
|
+
FTP_PORT = 21
|
77
|
+
CRLF = "\r\n"
|
78
|
+
DEFAULT_BLOCKSIZE = 4096
|
79
|
+
# :startdoc:
|
80
|
+
|
81
|
+
# When +true+, transfers are performed in binary mode. Default: +true+.
|
82
|
+
attr_reader :binary
|
83
|
+
|
84
|
+
# When +true+, the connection is in passive mode. Default: +false+.
|
85
|
+
attr_accessor :passive
|
86
|
+
|
87
|
+
# When +true+, all traffic to and from the server is written
|
88
|
+
# to +$stdout+. Default: +false+.
|
89
|
+
attr_accessor :debug_mode
|
90
|
+
|
91
|
+
# Sets or retrieves the +resume+ status, which decides whether incomplete
|
92
|
+
# transfers are resumed or restarted. Default: +false+.
|
93
|
+
attr_accessor :resume
|
94
|
+
|
95
|
+
# The server's welcome message.
|
96
|
+
attr_reader :welcome
|
97
|
+
|
98
|
+
# The server's last response code.
|
99
|
+
attr_reader :last_response_code
|
100
|
+
alias lastresp last_response_code
|
101
|
+
|
102
|
+
# The server's last response.
|
103
|
+
attr_reader :last_response
|
104
|
+
|
105
|
+
#
|
106
|
+
# A synonym for <tt>FTP.new</tt>, but with a mandatory host parameter.
|
107
|
+
#
|
108
|
+
# If a block is given, it is passed the +FTP+ object, which will be closed
|
109
|
+
# when the block finishes, or when an exception is raised.
|
110
|
+
#
|
111
|
+
def FTP.open(host, user = nil, passwd = nil, acct = nil)
|
112
|
+
if block_given?
|
113
|
+
ftp = new(host, user, passwd, acct)
|
114
|
+
begin
|
115
|
+
yield ftp
|
116
|
+
ensure
|
117
|
+
ftp.close
|
118
|
+
end
|
119
|
+
else
|
120
|
+
new(host, user, passwd, acct)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# Creates and returns a new +FTP+ object. If a +host+ is given, a connection
|
126
|
+
# is made. Additionally, if the +user+ is given, the given user name,
|
127
|
+
# password, and (optionally) account are used to log in. See #login.
|
128
|
+
#
|
129
|
+
def initialize(host = nil, user = nil, passwd = nil, acct = nil)
|
130
|
+
super()
|
131
|
+
@binary = false
|
132
|
+
@passive = false
|
133
|
+
@debug_mode = false
|
134
|
+
@resume = false
|
135
|
+
if host
|
136
|
+
connect(host)
|
137
|
+
if user
|
138
|
+
login(user, passwd, acct)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def binary=(newmode)
|
144
|
+
if newmode != @binary
|
145
|
+
@binary = newmode
|
146
|
+
@binary ? voidcmd("TYPE I") : voidcmd("TYPE A")
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def with_binary(newmode)
|
151
|
+
oldmode = binary
|
152
|
+
self.binary = newmode
|
153
|
+
begin
|
154
|
+
yield
|
155
|
+
ensure
|
156
|
+
self.binary = oldmode
|
157
|
+
end
|
158
|
+
end
|
159
|
+
private :with_binary
|
160
|
+
|
161
|
+
# Obsolete
|
162
|
+
def return_code
|
163
|
+
$stderr.puts("warning: Net::FTP#return_code is obsolete and do nothing")
|
164
|
+
return "\n"
|
165
|
+
end
|
166
|
+
|
167
|
+
# Obsolete
|
168
|
+
def return_code=(s)
|
169
|
+
$stderr.puts("warning: Net::FTP#return_code= is obsolete and do nothing")
|
170
|
+
end
|
171
|
+
|
172
|
+
def open_socket(host, port)
|
173
|
+
if defined? SOCKSSocket and ENV["SOCKS_SERVER"]
|
174
|
+
@passive = true
|
175
|
+
return SOCKSSocket.open(host, port)
|
176
|
+
else
|
177
|
+
return TCPSocket.open(host, port)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
private :open_socket
|
181
|
+
|
182
|
+
#
|
183
|
+
# Establishes an FTP connection to host, optionally overriding the default
|
184
|
+
# port. If the environment variable +SOCKS_SERVER+ is set, sets up the
|
185
|
+
# connection through a SOCKS proxy. Raises an exception (typically
|
186
|
+
# <tt>Errno::ECONNREFUSED</tt>) if the connection cannot be established.
|
187
|
+
#
|
188
|
+
def connect(host, port = FTP_PORT)
|
189
|
+
if @debug_mode
|
190
|
+
print "connect: ", host, ", ", port, "\n"
|
191
|
+
end
|
192
|
+
synchronize do
|
193
|
+
@sock = open_socket(host, port)
|
194
|
+
voidresp
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
#
|
199
|
+
# WRITEME or make private
|
200
|
+
#
|
201
|
+
def set_socket(sock, get_greeting = true)
|
202
|
+
synchronize do
|
203
|
+
@sock = sock
|
204
|
+
if get_greeting
|
205
|
+
voidresp
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def sanitize(s)
|
211
|
+
if s =~ /^PASS /i
|
212
|
+
return s[0, 5] + "*" * (s.length - 5)
|
213
|
+
else
|
214
|
+
return s
|
215
|
+
end
|
216
|
+
end
|
217
|
+
private :sanitize
|
218
|
+
|
219
|
+
def putline(line)
|
220
|
+
if @debug_mode
|
221
|
+
print "put: ", sanitize(line), "\n"
|
222
|
+
end
|
223
|
+
line = line + CRLF
|
224
|
+
@sock.write(line)
|
225
|
+
end
|
226
|
+
private :putline
|
227
|
+
|
228
|
+
def getline
|
229
|
+
line = @sock.readline # if get EOF, raise EOFError
|
230
|
+
line.sub!(/(\r\n|\n|\r)\z/n, "")
|
231
|
+
if @debug_mode
|
232
|
+
print "get: ", sanitize(line), "\n"
|
233
|
+
end
|
234
|
+
return line
|
235
|
+
end
|
236
|
+
private :getline
|
237
|
+
|
238
|
+
def getmultiline
|
239
|
+
line = getline
|
240
|
+
buff = line
|
241
|
+
if line[3] == ?-
|
242
|
+
code = line[0, 3]
|
243
|
+
begin
|
244
|
+
line = getline
|
245
|
+
buff << "\n" << line
|
246
|
+
end until line[0, 3] == code and line[3] != ?-
|
247
|
+
end
|
248
|
+
return buff << "\n"
|
249
|
+
end
|
250
|
+
private :getmultiline
|
251
|
+
|
252
|
+
def getresp
|
253
|
+
@last_response = getmultiline
|
254
|
+
@last_response_code = @last_response[0, 3]
|
255
|
+
case @last_response_code
|
256
|
+
when /\A[123]/
|
257
|
+
return @last_response
|
258
|
+
when /\A4/
|
259
|
+
raise FTPTempError, @last_response
|
260
|
+
when /\A5/
|
261
|
+
raise FTPPermError, @last_response
|
262
|
+
else
|
263
|
+
raise FTPProtoError, @last_response
|
264
|
+
end
|
265
|
+
end
|
266
|
+
private :getresp
|
267
|
+
|
268
|
+
def voidresp
|
269
|
+
resp = getresp
|
270
|
+
if resp[0] != ?2
|
271
|
+
raise FTPReplyError, resp
|
272
|
+
end
|
273
|
+
end
|
274
|
+
private :voidresp
|
275
|
+
|
276
|
+
#
|
277
|
+
# Sends a command and returns the response.
|
278
|
+
#
|
279
|
+
def sendcmd(cmd)
|
280
|
+
synchronize do
|
281
|
+
putline(cmd)
|
282
|
+
return getresp
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
#
|
287
|
+
# Sends a command and expect a response beginning with '2'.
|
288
|
+
#
|
289
|
+
def voidcmd(cmd)
|
290
|
+
synchronize do
|
291
|
+
putline(cmd)
|
292
|
+
voidresp
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
def sendport(host, port)
|
297
|
+
af = (@sock.peeraddr)[0]
|
298
|
+
if af == "AF_INET"
|
299
|
+
cmd = "PORT " + (host.split(".") + port.divmod(256)).join(",")
|
300
|
+
elsif af == "AF_INET6"
|
301
|
+
cmd = sprintf("EPRT |2|%s|%d|", host, port)
|
302
|
+
else
|
303
|
+
raise FTPProtoError, host
|
304
|
+
end
|
305
|
+
voidcmd(cmd)
|
306
|
+
end
|
307
|
+
private :sendport
|
308
|
+
|
309
|
+
def makeport
|
310
|
+
sock = TCPServer.open(@sock.addr[3], 0)
|
311
|
+
port = sock.addr[1]
|
312
|
+
host = sock.addr[3]
|
313
|
+
resp = sendport(host, port)
|
314
|
+
return sock
|
315
|
+
end
|
316
|
+
private :makeport
|
317
|
+
|
318
|
+
def makepasv
|
319
|
+
if @sock.peeraddr[0] == "AF_INET"
|
320
|
+
host, port = parse227(sendcmd("PASV"))
|
321
|
+
else
|
322
|
+
host, port = parse229(sendcmd("EPSV"))
|
323
|
+
# host, port = parse228(sendcmd("LPSV"))
|
324
|
+
end
|
325
|
+
return host, port
|
326
|
+
end
|
327
|
+
private :makepasv
|
328
|
+
|
329
|
+
def transfercmd(cmd, rest_offset = nil)
|
330
|
+
if @passive
|
331
|
+
host, port = makepasv
|
332
|
+
conn = open_socket(host, port)
|
333
|
+
if @resume and rest_offset
|
334
|
+
resp = sendcmd("REST " + rest_offset.to_s)
|
335
|
+
if resp[0] != ?3
|
336
|
+
raise FTPReplyError, resp
|
337
|
+
end
|
338
|
+
end
|
339
|
+
resp = sendcmd(cmd)
|
340
|
+
# skip 2XX for some ftp servers
|
341
|
+
resp = getresp if resp[0] == ?2
|
342
|
+
if resp[0] != ?1
|
343
|
+
raise FTPReplyError, resp
|
344
|
+
end
|
345
|
+
else
|
346
|
+
sock = makeport
|
347
|
+
if @resume and rest_offset
|
348
|
+
resp = sendcmd("REST " + rest_offset.to_s)
|
349
|
+
if resp[0] != ?3
|
350
|
+
raise FTPReplyError, resp
|
351
|
+
end
|
352
|
+
end
|
353
|
+
resp = sendcmd(cmd)
|
354
|
+
# skip 2XX for some ftp servers
|
355
|
+
resp = getresp if resp[0] == ?2
|
356
|
+
if resp[0] != ?1
|
357
|
+
raise FTPReplyError, resp
|
358
|
+
end
|
359
|
+
conn = sock.accept
|
360
|
+
sock.close
|
361
|
+
end
|
362
|
+
return conn
|
363
|
+
end
|
364
|
+
private :transfercmd
|
365
|
+
|
366
|
+
def getaddress
|
367
|
+
thishost = Socket.gethostname
|
368
|
+
if not thishost.index(".")
|
369
|
+
thishost = Socket.gethostbyname(thishost)[0]
|
370
|
+
end
|
371
|
+
if ENV.has_key?("LOGNAME")
|
372
|
+
realuser = ENV["LOGNAME"]
|
373
|
+
elsif ENV.has_key?("USER")
|
374
|
+
realuser = ENV["USER"]
|
375
|
+
else
|
376
|
+
realuser = "anonymous"
|
377
|
+
end
|
378
|
+
return realuser + "@" + thishost
|
379
|
+
end
|
380
|
+
private :getaddress
|
381
|
+
|
382
|
+
#
|
383
|
+
# Logs in to the remote host. The session must have been previously
|
384
|
+
# connected. If +user+ is the string "anonymous" and the +password+ is
|
385
|
+
# +nil+, a password of <tt>user@host</tt> is synthesized. If the +acct+
|
386
|
+
# parameter is not +nil+, an FTP ACCT command is sent following the
|
387
|
+
# successful login. Raises an exception on error (typically
|
388
|
+
# <tt>Net::FTPPermError</tt>).
|
389
|
+
#
|
390
|
+
def login(user = "anonymous", passwd = nil, acct = nil)
|
391
|
+
if user == "anonymous" and passwd == nil
|
392
|
+
passwd = getaddress
|
393
|
+
end
|
394
|
+
|
395
|
+
resp = ""
|
396
|
+
synchronize do
|
397
|
+
resp = sendcmd('USER ' + user)
|
398
|
+
if resp[0] == ?3
|
399
|
+
raise FTPReplyError, resp if passwd.nil?
|
400
|
+
resp = sendcmd('PASS ' + passwd)
|
401
|
+
end
|
402
|
+
if resp[0] == ?3
|
403
|
+
raise FTPReplyError, resp if acct.nil?
|
404
|
+
resp = sendcmd('ACCT ' + acct)
|
405
|
+
end
|
406
|
+
end
|
407
|
+
if resp[0] != ?2
|
408
|
+
raise FTPReplyError, resp
|
409
|
+
end
|
410
|
+
@welcome = resp
|
411
|
+
self.binary = true
|
412
|
+
end
|
413
|
+
|
414
|
+
#
|
415
|
+
# Puts the connection into binary (image) mode, issues the given command,
|
416
|
+
# and fetches the data returned, passing it to the associated block in
|
417
|
+
# chunks of +blocksize+ characters. Note that +cmd+ is a server command
|
418
|
+
# (such as "RETR myfile").
|
419
|
+
#
|
420
|
+
def retrbinary(cmd, blocksize, rest_offset = nil) # :yield: data
|
421
|
+
synchronize do
|
422
|
+
with_binary(true) do
|
423
|
+
conn = transfercmd(cmd, rest_offset)
|
424
|
+
loop do
|
425
|
+
data = conn.read(blocksize)
|
426
|
+
break if data == nil
|
427
|
+
yield(data)
|
428
|
+
end
|
429
|
+
conn.close
|
430
|
+
voidresp
|
431
|
+
end
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
#
|
436
|
+
# Puts the connection into ASCII (text) mode, issues the given command, and
|
437
|
+
# passes the resulting data, one line at a time, to the associated block. If
|
438
|
+
# no block is given, prints the lines. Note that +cmd+ is a server command
|
439
|
+
# (such as "RETR myfile").
|
440
|
+
#
|
441
|
+
def retrlines(cmd) # :yield: line
|
442
|
+
synchronize do
|
443
|
+
with_binary(false) do
|
444
|
+
conn = transfercmd(cmd)
|
445
|
+
loop do
|
446
|
+
line = conn.gets
|
447
|
+
break if line == nil
|
448
|
+
if line[-2, 2] == CRLF
|
449
|
+
line = line[0 .. -3]
|
450
|
+
elsif line[-1] == ?\n
|
451
|
+
line = line[0 .. -2]
|
452
|
+
end
|
453
|
+
yield(line)
|
454
|
+
end
|
455
|
+
conn.close
|
456
|
+
voidresp
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
#
|
462
|
+
# Puts the connection into binary (image) mode, issues the given server-side
|
463
|
+
# command (such as "STOR myfile"), and sends the contents of the file named
|
464
|
+
# +file+ to the server. If the optional block is given, it also passes it
|
465
|
+
# the data, in chunks of +blocksize+ characters.
|
466
|
+
#
|
467
|
+
def storbinary(cmd, file, blocksize, rest_offset = nil, &block) # :yield: data
|
468
|
+
if rest_offset
|
469
|
+
file.seek(rest_offset, IO::SEEK_SET)
|
470
|
+
end
|
471
|
+
synchronize do
|
472
|
+
with_binary(true) do
|
473
|
+
conn = transfercmd(cmd, rest_offset)
|
474
|
+
loop do
|
475
|
+
buf = file.read(blocksize)
|
476
|
+
break if buf == nil
|
477
|
+
conn.write(buf)
|
478
|
+
yield(buf) if block
|
479
|
+
end
|
480
|
+
conn.close
|
481
|
+
voidresp
|
482
|
+
end
|
483
|
+
end
|
484
|
+
rescue Errno::EPIPE
|
485
|
+
# EPIPE, in this case, means that the data connection was unexpectedly
|
486
|
+
# terminated. Rather than just raising EPIPE to the caller, check the
|
487
|
+
# response on the control connection. If getresp doesn't raise a more
|
488
|
+
# appropriate exception, re-raise the original exception.
|
489
|
+
getresp
|
490
|
+
raise
|
491
|
+
end
|
492
|
+
|
493
|
+
#
|
494
|
+
# Puts the connection into ASCII (text) mode, issues the given server-side
|
495
|
+
# command (such as "STOR myfile"), and sends the contents of the file
|
496
|
+
# named +file+ to the server, one line at a time. If the optional block is
|
497
|
+
# given, it also passes it the lines.
|
498
|
+
#
|
499
|
+
def storlines(cmd, file, &block) # :yield: line
|
500
|
+
synchronize do
|
501
|
+
with_binary(false) do
|
502
|
+
conn = transfercmd(cmd)
|
503
|
+
loop do
|
504
|
+
buf = file.gets
|
505
|
+
break if buf == nil
|
506
|
+
if buf[-2, 2] != CRLF
|
507
|
+
buf = buf.chomp + CRLF
|
508
|
+
end
|
509
|
+
conn.write(buf)
|
510
|
+
yield(buf) if block
|
511
|
+
end
|
512
|
+
conn.close
|
513
|
+
voidresp
|
514
|
+
end
|
515
|
+
end
|
516
|
+
rescue Errno::EPIPE
|
517
|
+
# EPIPE, in this case, means that the data connection was unexpectedly
|
518
|
+
# terminated. Rather than just raising EPIPE to the caller, check the
|
519
|
+
# response on the control connection. If getresp doesn't raise a more
|
520
|
+
# appropriate exception, re-raise the original exception.
|
521
|
+
getresp
|
522
|
+
raise
|
523
|
+
end
|
524
|
+
|
525
|
+
#
|
526
|
+
# Retrieves +remotefile+ in binary mode, storing the result in +localfile+.
|
527
|
+
# If +localfile+ is nil, returns retrieved data.
|
528
|
+
# If a block is supplied, it is passed the retrieved data in +blocksize+
|
529
|
+
# chunks.
|
530
|
+
#
|
531
|
+
def getbinaryfile(remotefile, localfile = File.basename(remotefile),
|
532
|
+
blocksize = DEFAULT_BLOCKSIZE) # :yield: data
|
533
|
+
result = nil
|
534
|
+
if localfile
|
535
|
+
if @resume
|
536
|
+
rest_offset = File.size?(localfile)
|
537
|
+
f = open(localfile, "a")
|
538
|
+
else
|
539
|
+
rest_offset = nil
|
540
|
+
f = open(localfile, "w")
|
541
|
+
end
|
542
|
+
elsif !block_given?
|
543
|
+
result = ""
|
544
|
+
end
|
545
|
+
begin
|
546
|
+
f.binmode if localfile
|
547
|
+
retrbinary("RETR " + remotefile, blocksize, rest_offset) do |data|
|
548
|
+
f.write(data) if localfile
|
549
|
+
yield(data) if block_given?
|
550
|
+
result.concat(data) if result
|
551
|
+
end
|
552
|
+
return result
|
553
|
+
ensure
|
554
|
+
f.close if localfile
|
555
|
+
end
|
556
|
+
end
|
557
|
+
|
558
|
+
#
|
559
|
+
# Retrieves +remotefile+ in ASCII (text) mode, storing the result in
|
560
|
+
# +localfile+.
|
561
|
+
# If +localfile+ is nil, returns retrieved data.
|
562
|
+
# If a block is supplied, it is passed the retrieved data one
|
563
|
+
# line at a time.
|
564
|
+
#
|
565
|
+
def gettextfile(remotefile, localfile = File.basename(remotefile)) # :yield: line
|
566
|
+
result = nil
|
567
|
+
if localfile
|
568
|
+
f = open(localfile, "w")
|
569
|
+
elsif !block_given?
|
570
|
+
result = ""
|
571
|
+
end
|
572
|
+
begin
|
573
|
+
retrlines("RETR " + remotefile) do |line|
|
574
|
+
f.puts(line) if localfile
|
575
|
+
yield(line) if block_given?
|
576
|
+
result.concat(line + "\n") if result
|
577
|
+
end
|
578
|
+
return result
|
579
|
+
ensure
|
580
|
+
f.close if localfile
|
581
|
+
end
|
582
|
+
end
|
583
|
+
|
584
|
+
#
|
585
|
+
# Retrieves +remotefile+ in whatever mode the session is set (text or
|
586
|
+
# binary). See #gettextfile and #getbinaryfile.
|
587
|
+
#
|
588
|
+
def get(remotefile, localfile = File.basename(remotefile),
|
589
|
+
blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
|
590
|
+
if @binary
|
591
|
+
getbinaryfile(remotefile, localfile, blocksize, &block)
|
592
|
+
else
|
593
|
+
gettextfile(remotefile, localfile, &block)
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
#
|
598
|
+
# Transfers +localfile+ to the server in binary mode, storing the result in
|
599
|
+
# +remotefile+. If a block is supplied, calls it, passing in the transmitted
|
600
|
+
# data in +blocksize+ chunks.
|
601
|
+
#
|
602
|
+
def putbinaryfile(localfile, remotefile = File.basename(localfile),
|
603
|
+
blocksize = DEFAULT_BLOCKSIZE, &block) # :yield: data
|
604
|
+
if @resume
|
605
|
+
begin
|
606
|
+
rest_offset = size(remotefile)
|
607
|
+
rescue Net::FTPPermError
|
608
|
+
rest_offset = nil
|
609
|
+
end
|
610
|
+
else
|
611
|
+
rest_offset = nil
|
612
|
+
end
|
613
|
+
f = open(localfile)
|
614
|
+
begin
|
615
|
+
f.binmode
|
616
|
+
storbinary("STOR " + remotefile, f, blocksize, rest_offset, &block)
|
617
|
+
ensure
|
618
|
+
f.close
|
619
|
+
end
|
620
|
+
end
|
621
|
+
|
622
|
+
#
|
623
|
+
# Transfers +localfile+ to the server in ASCII (text) mode, storing the result
|
624
|
+
# in +remotefile+. If callback or an associated block is supplied, calls it,
|
625
|
+
# passing in the transmitted data one line at a time.
|
626
|
+
#
|
627
|
+
def puttextfile(localfile, remotefile = File.basename(localfile), &block) # :yield: line
|
628
|
+
f = open(localfile)
|
629
|
+
begin
|
630
|
+
storlines("STOR " + remotefile, f, &block)
|
631
|
+
ensure
|
632
|
+
f.close
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
#
|
637
|
+
# Transfers +localfile+ to the server in whatever mode the session is set
|
638
|
+
# (text or binary). See #puttextfile and #putbinaryfile.
|
639
|
+
#
|
640
|
+
def put(localfile, remotefile = File.basename(localfile),
|
641
|
+
blocksize = DEFAULT_BLOCKSIZE, &block)
|
642
|
+
if @binary
|
643
|
+
putbinaryfile(localfile, remotefile, blocksize, &block)
|
644
|
+
else
|
645
|
+
puttextfile(localfile, remotefile, &block)
|
646
|
+
end
|
647
|
+
end
|
648
|
+
|
649
|
+
#
|
650
|
+
# Sends the ACCT command. TODO: more info.
|
651
|
+
#
|
652
|
+
def acct(account)
|
653
|
+
cmd = "ACCT " + account
|
654
|
+
voidcmd(cmd)
|
655
|
+
end
|
656
|
+
|
657
|
+
#
|
658
|
+
# Returns an array of filenames in the remote directory.
|
659
|
+
#
|
660
|
+
def nlst(dir = nil)
|
661
|
+
cmd = "NLST"
|
662
|
+
if dir
|
663
|
+
cmd = cmd + " " + dir
|
664
|
+
end
|
665
|
+
files = []
|
666
|
+
retrlines(cmd) do |line|
|
667
|
+
files.push(line)
|
668
|
+
end
|
669
|
+
return files
|
670
|
+
end
|
671
|
+
|
672
|
+
#
|
673
|
+
# Returns an array of file information in the directory (the output is like
|
674
|
+
# `ls -l`). If a block is given, it iterates through the listing.
|
675
|
+
#
|
676
|
+
def list(*args, &block) # :yield: line
|
677
|
+
cmd = "LIST"
|
678
|
+
args.each do |arg|
|
679
|
+
cmd = cmd + " " + arg
|
680
|
+
end
|
681
|
+
if block
|
682
|
+
retrlines(cmd, &block)
|
683
|
+
else
|
684
|
+
lines = []
|
685
|
+
retrlines(cmd) do |line|
|
686
|
+
lines << line
|
687
|
+
end
|
688
|
+
return lines
|
689
|
+
end
|
690
|
+
end
|
691
|
+
alias ls list
|
692
|
+
alias dir list
|
693
|
+
|
694
|
+
#
|
695
|
+
# Renames a file on the server.
|
696
|
+
#
|
697
|
+
def rename(fromname, toname)
|
698
|
+
resp = sendcmd("RNFR " + fromname)
|
699
|
+
if resp[0] != ?3
|
700
|
+
raise FTPReplyError, resp
|
701
|
+
end
|
702
|
+
voidcmd("RNTO " + toname)
|
703
|
+
end
|
704
|
+
|
705
|
+
#
|
706
|
+
# Deletes a file on the server.
|
707
|
+
#
|
708
|
+
def delete(filename)
|
709
|
+
resp = sendcmd("DELE " + filename)
|
710
|
+
if resp[0, 3] == "250"
|
711
|
+
return
|
712
|
+
elsif resp[0] == ?5
|
713
|
+
raise FTPPermError, resp
|
714
|
+
else
|
715
|
+
raise FTPReplyError, resp
|
716
|
+
end
|
717
|
+
end
|
718
|
+
|
719
|
+
#
|
720
|
+
# Changes the (remote) directory.
|
721
|
+
#
|
722
|
+
def chdir(dirname)
|
723
|
+
if dirname == ".."
|
724
|
+
begin
|
725
|
+
voidcmd("CDUP")
|
726
|
+
return
|
727
|
+
rescue FTPPermError => e
|
728
|
+
if e.message[0, 3] != "500"
|
729
|
+
raise e
|
730
|
+
end
|
731
|
+
end
|
732
|
+
end
|
733
|
+
cmd = "CWD " + dirname
|
734
|
+
voidcmd(cmd)
|
735
|
+
end
|
736
|
+
|
737
|
+
#
|
738
|
+
# Returns the size of the given (remote) filename.
|
739
|
+
#
|
740
|
+
def size(filename)
|
741
|
+
with_binary(true) do
|
742
|
+
resp = sendcmd("SIZE " + filename)
|
743
|
+
if resp[0, 3] != "213"
|
744
|
+
raise FTPReplyError, resp
|
745
|
+
end
|
746
|
+
return resp[3..-1].strip.to_i
|
747
|
+
end
|
748
|
+
end
|
749
|
+
|
750
|
+
MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/ # :nodoc:
|
751
|
+
|
752
|
+
#
|
753
|
+
# Returns the last modification time of the (remote) file. If +local+ is
|
754
|
+
# +true+, it is returned as a local time, otherwise it's a UTC time.
|
755
|
+
#
|
756
|
+
def mtime(filename, local = false)
|
757
|
+
str = mdtm(filename)
|
758
|
+
ary = str.scan(MDTM_REGEXP)[0].collect {|i| i.to_i}
|
759
|
+
return local ? Time.local(*ary) : Time.gm(*ary)
|
760
|
+
end
|
761
|
+
|
762
|
+
#
|
763
|
+
# Creates a remote directory.
|
764
|
+
#
|
765
|
+
def mkdir(dirname)
|
766
|
+
resp = sendcmd("MKD " + dirname)
|
767
|
+
return parse257(resp)
|
768
|
+
end
|
769
|
+
|
770
|
+
#
|
771
|
+
# Removes a remote directory.
|
772
|
+
#
|
773
|
+
def rmdir(dirname)
|
774
|
+
voidcmd("RMD " + dirname)
|
775
|
+
end
|
776
|
+
|
777
|
+
#
|
778
|
+
# Returns the current remote directory.
|
779
|
+
#
|
780
|
+
def pwd
|
781
|
+
resp = sendcmd("PWD")
|
782
|
+
return parse257(resp)
|
783
|
+
end
|
784
|
+
alias getdir pwd
|
785
|
+
|
786
|
+
#
|
787
|
+
# Returns system information.
|
788
|
+
#
|
789
|
+
def system
|
790
|
+
resp = sendcmd("SYST")
|
791
|
+
if resp[0, 3] != "215"
|
792
|
+
raise FTPReplyError, resp
|
793
|
+
end
|
794
|
+
return resp[4 .. -1]
|
795
|
+
end
|
796
|
+
|
797
|
+
#
|
798
|
+
# Aborts the previous command (ABOR command).
|
799
|
+
#
|
800
|
+
def abort
|
801
|
+
line = "ABOR" + CRLF
|
802
|
+
print "put: ABOR\n" if @debug_mode
|
803
|
+
@sock.send(line, Socket::MSG_OOB)
|
804
|
+
resp = getmultiline
|
805
|
+
unless ["426", "226", "225"].include?(resp[0, 3])
|
806
|
+
raise FTPProtoError, resp
|
807
|
+
end
|
808
|
+
return resp
|
809
|
+
end
|
810
|
+
|
811
|
+
#
|
812
|
+
# Returns the status (STAT command).
|
813
|
+
#
|
814
|
+
def status
|
815
|
+
line = "STAT" + CRLF
|
816
|
+
print "put: STAT\n" if @debug_mode
|
817
|
+
@sock.send(line, Socket::MSG_OOB)
|
818
|
+
return getresp
|
819
|
+
end
|
820
|
+
|
821
|
+
#
|
822
|
+
# Issues the MDTM command. TODO: more info.
|
823
|
+
#
|
824
|
+
def mdtm(filename)
|
825
|
+
resp = sendcmd("MDTM " + filename)
|
826
|
+
if resp[0, 3] == "213"
|
827
|
+
return resp[3 .. -1].strip
|
828
|
+
end
|
829
|
+
end
|
830
|
+
|
831
|
+
#
|
832
|
+
# Issues the HELP command.
|
833
|
+
#
|
834
|
+
def help(arg = nil)
|
835
|
+
cmd = "HELP"
|
836
|
+
if arg
|
837
|
+
cmd = cmd + " " + arg
|
838
|
+
end
|
839
|
+
sendcmd(cmd)
|
840
|
+
end
|
841
|
+
|
842
|
+
#
|
843
|
+
# Exits the FTP session.
|
844
|
+
#
|
845
|
+
def quit
|
846
|
+
voidcmd("QUIT")
|
847
|
+
end
|
848
|
+
|
849
|
+
#
|
850
|
+
# Issues a NOOP command.
|
851
|
+
#
|
852
|
+
def noop
|
853
|
+
voidcmd("NOOP")
|
854
|
+
end
|
855
|
+
|
856
|
+
#
|
857
|
+
# Issues a SITE command.
|
858
|
+
#
|
859
|
+
def site(arg)
|
860
|
+
cmd = "SITE " + arg
|
861
|
+
voidcmd(cmd)
|
862
|
+
end
|
863
|
+
|
864
|
+
#
|
865
|
+
# Closes the connection. Further operations are impossible until you open
|
866
|
+
# a new connection with #connect.
|
867
|
+
#
|
868
|
+
def close
|
869
|
+
@sock.close if @sock and not @sock.closed?
|
870
|
+
end
|
871
|
+
|
872
|
+
#
|
873
|
+
# Returns +true+ iff the connection is closed.
|
874
|
+
#
|
875
|
+
def closed?
|
876
|
+
@sock == nil or @sock.closed?
|
877
|
+
end
|
878
|
+
|
879
|
+
def parse227(resp)
|
880
|
+
if resp[0, 3] != "227"
|
881
|
+
raise FTPReplyError, resp
|
882
|
+
end
|
883
|
+
left = resp.index("(")
|
884
|
+
right = resp.index(")")
|
885
|
+
if left == nil or right == nil
|
886
|
+
raise FTPProtoError, resp
|
887
|
+
end
|
888
|
+
numbers = resp[left + 1 .. right - 1].split(",")
|
889
|
+
if numbers.length != 6
|
890
|
+
raise FTPProtoError, resp
|
891
|
+
end
|
892
|
+
host = numbers[0, 4].join(".")
|
893
|
+
port = (numbers[4].to_i << 8) + numbers[5].to_i
|
894
|
+
return host, port
|
895
|
+
end
|
896
|
+
private :parse227
|
897
|
+
|
898
|
+
def parse228(resp)
|
899
|
+
if resp[0, 3] != "228"
|
900
|
+
raise FTPReplyError, resp
|
901
|
+
end
|
902
|
+
left = resp.index("(")
|
903
|
+
right = resp.index(")")
|
904
|
+
if left == nil or right == nil
|
905
|
+
raise FTPProtoError, resp
|
906
|
+
end
|
907
|
+
numbers = resp[left + 1 .. right - 1].split(",")
|
908
|
+
if numbers[0] == "4"
|
909
|
+
if numbers.length != 9 || numbers[1] != "4" || numbers[2 + 4] != "2"
|
910
|
+
raise FTPProtoError, resp
|
911
|
+
end
|
912
|
+
host = numbers[2, 4].join(".")
|
913
|
+
port = (numbers[7].to_i << 8) + numbers[8].to_i
|
914
|
+
elsif numbers[0] == "6"
|
915
|
+
if numbers.length != 21 || numbers[1] != "16" || numbers[2 + 16] != "2"
|
916
|
+
raise FTPProtoError, resp
|
917
|
+
end
|
918
|
+
v6 = ["", "", "", "", "", "", "", ""]
|
919
|
+
for i in 0 .. 7
|
920
|
+
v6[i] = sprintf("%02x%02x", numbers[(i * 2) + 2].to_i,
|
921
|
+
numbers[(i * 2) + 3].to_i)
|
922
|
+
end
|
923
|
+
host = v6[0, 8].join(":")
|
924
|
+
port = (numbers[19].to_i << 8) + numbers[20].to_i
|
925
|
+
end
|
926
|
+
return host, port
|
927
|
+
end
|
928
|
+
private :parse228
|
929
|
+
|
930
|
+
def parse229(resp)
|
931
|
+
if resp[0, 3] != "229"
|
932
|
+
raise FTPReplyError, resp
|
933
|
+
end
|
934
|
+
left = resp.index("(")
|
935
|
+
right = resp.index(")")
|
936
|
+
if left == nil or right == nil
|
937
|
+
raise FTPProtoError, resp
|
938
|
+
end
|
939
|
+
numbers = resp[left + 1 .. right - 1].split(resp[left + 1, 1])
|
940
|
+
if numbers.length != 4
|
941
|
+
raise FTPProtoError, resp
|
942
|
+
end
|
943
|
+
port = numbers[3].to_i
|
944
|
+
host = (@sock.peeraddr())[3]
|
945
|
+
return host, port
|
946
|
+
end
|
947
|
+
private :parse229
|
948
|
+
|
949
|
+
def parse257(resp)
|
950
|
+
if resp[0, 3] != "257"
|
951
|
+
raise FTPReplyError, resp
|
952
|
+
end
|
953
|
+
if resp[3, 2] != ' "'
|
954
|
+
return ""
|
955
|
+
end
|
956
|
+
dirname = ""
|
957
|
+
i = 5
|
958
|
+
n = resp.length
|
959
|
+
while i < n
|
960
|
+
c = resp[i, 1]
|
961
|
+
i = i + 1
|
962
|
+
if c == '"'
|
963
|
+
if i > n or resp[i, 1] != '"'
|
964
|
+
break
|
965
|
+
end
|
966
|
+
i = i + 1
|
967
|
+
end
|
968
|
+
dirname = dirname + c
|
969
|
+
end
|
970
|
+
return dirname
|
971
|
+
end
|
972
|
+
private :parse257
|
973
|
+
end
|
974
|
+
|
975
|
+
end
|
976
|
+
|
977
|
+
|
978
|
+
# Documentation comments:
|
979
|
+
# - sourced from pickaxe and nutshell, with improvements (hopefully)
|
980
|
+
# - three methods should be private (search WRITEME)
|
981
|
+
# - two methods need more information (search TODO)
|