rhodes 2.0.0.beta2 → 2.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +2 -0
- data/Manifest.txt +27 -148
- data/Rakefile +49 -3
- data/lib/framework/builtinME.rb +6 -0
- data/lib/framework/rho/render.rb +13 -8
- data/lib/framework/rho/rho.rb +97 -43
- data/lib/framework/rho/rhoapplication.rb +8 -3
- data/lib/framework/rho/rhocontroller.rb +1 -1
- data/lib/framework/rhodes-framework.rb +1 -1
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhoframework.rb +7 -22
- data/lib/framework/rhofsconnector.rb +1 -1
- data/lib/framework/rholang/localization_simplified.rb +2 -2
- data/lib/framework/rhom/rhom.rb +1 -0
- data/lib/framework/rhom/rhom_db_adapter.rb +2 -2
- data/lib/framework/rhom/rhom_model.rb +98 -0
- data/lib/framework/rhom/rhom_object_factory.rb +13 -12
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/jni/include/{JNIRhodes.h → rhodes/JNIRhodes.h} +3 -54
- data/platform/android/Rhodes/jni/include/{RhoClassFactory.h → rhodes/RhoClassFactory.h} +0 -0
- data/platform/android/Rhodes/jni/include/{SystemInfoImpl.h → rhodes/SystemInfoImpl.h} +0 -0
- data/platform/android/Rhodes/jni/include/{details → rhodes/details}/rhojava.inc +1 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_Logger.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoConf.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoLogConf.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoMenu.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_Rhodes.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_SplashScreen.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_alert_Alert.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_camera_Camera.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_datetime_DateTimePicker.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_geolocation_GeoLocationImpl.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_socket_RhoSocketImpl.h +0 -0
- data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_socket_SSLImpl.h +0 -0
- data/platform/android/Rhodes/jni/include/{sslimpl.h → rhodes/sslimpl.h} +0 -0
- data/platform/android/Rhodes/jni/include/rhodes.h +59 -0
- data/platform/android/Rhodes/jni/src/RhoClassFactory.cpp +3 -3
- data/platform/android/Rhodes/jni/src/alert.cpp +2 -2
- data/platform/android/Rhodes/jni/src/callbacks.cpp +4 -3
- data/platform/android/Rhodes/jni/src/camera.cpp +2 -2
- data/platform/android/Rhodes/jni/src/datetimepicker.cpp +2 -2
- data/platform/android/Rhodes/jni/src/geolocation.cpp +2 -2
- data/platform/android/Rhodes/jni/src/logconf.cpp +2 -2
- data/platform/android/Rhodes/jni/src/logger.cpp +2 -2
- data/platform/android/Rhodes/jni/src/mapview.cpp +1 -1
- data/platform/android/Rhodes/jni/src/menu.cpp +2 -2
- data/platform/android/Rhodes/jni/src/nativebar.cpp +1 -1
- data/platform/android/Rhodes/jni/src/navbar.cpp +17 -3
- data/platform/android/Rhodes/jni/src/phonebook.cpp +1 -1
- data/platform/android/Rhodes/jni/src/rhoconf.cpp +2 -2
- data/platform/android/Rhodes/jni/src/rhodes.cpp +3 -3
- data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
- data/platform/android/Rhodes/jni/src/socketimpl.cpp +2 -2
- data/platform/android/Rhodes/jni/src/splashscreen.cpp +2 -2
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -3
- data/platform/android/Rhodes/jni/src/syncengine.cpp +2 -2
- data/platform/android/Rhodes/jni/src/webview.cpp +15 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeLibraries.java +11 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NavBar.java +52 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +8 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +26 -28
- data/platform/android/build/RhodesSRC_build.files +21 -20
- data/platform/android/build/android.rake +69 -24
- data/platform/android/build/androidcommon.rb +17 -12
- data/platform/bb/build/bb.rake +23 -21
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +5 -2
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +6 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +9 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +31 -2
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +17 -6
- data/platform/bb/rhodes/src/rhomobile/Utilities.java +6 -0
- data/platform/iphone/Classes/AppManager/AppManager.m +16 -4
- data/platform/iphone/Classes/DateTime.h +5 -6
- data/platform/iphone/Classes/DateTimePicker.m +4 -18
- data/platform/iphone/Classes/DateTimePickerDelegate.h +7 -9
- data/platform/iphone/Classes/DateTimePickerDelegate.m +141 -152
- data/platform/iphone/Classes/Rhodes.h +6 -1
- data/platform/iphone/Classes/Rhodes.m +17 -43
- data/platform/iphone/Classes/SimpleMainView.h +1 -1
- data/platform/iphone/Classes/SimpleMainView.m +54 -4
- data/platform/iphone/Classes/WebView.m +17 -0
- data/platform/iphone/rbuild/iphone.rake +1 -0
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +0 -45
- data/platform/shared/common/PosixThreadImpl.cpp +8 -0
- data/platform/shared/common/PosixThreadImpl.h +1 -0
- data/platform/shared/common/RhoThread.cpp +1 -0
- data/platform/shared/common/RhoThread.h +4 -2
- data/platform/shared/curl/include/curl/curl.h +4 -0
- data/platform/shared/db/DBAdapter.cpp +47 -60
- data/platform/shared/db/DBAdapter.h +6 -2
- data/platform/shared/net/AsyncHttp.cpp +27 -11
- data/platform/shared/net/AsyncHttp.h +3 -1
- data/platform/shared/net/CURLNetRequest.cpp +11 -10
- data/platform/shared/net/CURLNetRequest.h +6 -4
- data/platform/shared/net/HttpServer.cpp +11 -6
- data/platform/shared/ruby/ext/asynchttp/asynchttp.i +2 -2
- data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +22 -11
- data/platform/shared/ruby/ext/rho/rhoruby.c +2 -2
- data/platform/shared/ruby/ext/rho/rhosupport.c +23 -3
- data/platform/shared/ruby/ext/webview/webview.i +4 -0
- data/platform/shared/ruby/ext/webview/webview_wrap.c +39 -0
- data/platform/shared/ruby/re.c +8 -0
- data/platform/shared/ruby/string.c +1 -1
- data/platform/shared/rubyJVM/src/com/rho/IRhoRubyHelper.java +1 -0
- data/platform/shared/rubyJVM/src/com/rho/RhoClassFactory.java +6 -1
- data/platform/shared/rubyJVM/src/com/rho/RhoThread.java +3 -0
- data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +34 -0
- data/platform/shared/rubyJVM/src/com/rho/db/DBAdapter.java +40 -53
- data/platform/shared/rubyJVM/src/com/rho/net/AsyncHttp.java +32 -15
- data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +31 -17
- data/platform/shared/rubyJVM/src/com/rho/net/RhoConnection.java +3 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/JSONArrayIterator.java +17 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +158 -137
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java +18 -17
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncThread.java +10 -2
- data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubyFile_Methods.java +6 -0
- data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyFile.java +18 -3
- data/platform/shared/rubyJVM/src/j2me/io/File.java +37 -9
- data/platform/shared/sqlite/sqlite3.c +14613 -13016
- data/platform/shared/sqlite/sqlite3.h +1461 -1499
- data/platform/shared/sqlite/sqlite3ext.h +0 -2
- data/platform/shared/sync/ClientRegister.cpp +3 -3
- data/platform/shared/sync/ClientRegister.h +2 -1
- data/platform/shared/sync/SyncEngine.cpp +20 -8
- data/platform/shared/sync/SyncSource.cpp +12 -12
- data/platform/shared/sync/SyncSource.h +4 -4
- data/platform/shared/sync/SyncThread.cpp +8 -1
- data/platform/shared/tcmalloc/rhomem.h +3 -0
- data/platform/shared/tcmalloc/tcmalloc_.cpp +11 -0
- data/platform/wm/rhodes/Alert.cpp +148 -101
- data/platform/wm/rhodes/Alert.h +4 -1
- data/platform/wm/rhodes/AppManager.cpp +212 -72
- data/platform/wm/rhodes/AppManager.h +24 -3
- data/platform/wm/rhodes/DateTimePicker.cpp +23 -11
- data/platform/wm/rhodes/DateTimePicker.h +16 -5
- data/platform/wm/rhodes/MainWindow.cpp +22 -7
- data/platform/wm/rhodes/OkCancelModalDialog.h +63 -0
- data/platform/wm/rhodes/Rhodes.cpp +29 -17
- data/platform/wm/rhodes/phonebook/NativeAddressBook.cpp +128 -4
- data/platform/wm/rhodes/phonebook/NativeAddressBook.h +33 -3
- data/platform/wm/rhodes/resource.h +1 -1
- data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +5 -0
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +136 -102
- data/platform/wm/rhodes/rho/net/NetRequestImpl.h +12 -5
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +24 -10
- data/platform/wm/rhodes/rho/rubyext/WebView.cpp +6 -0
- data/platform/wm/rhodes/rhodes.vcproj +4 -0
- data/platform/wm/tools/detool/detool.cpp +17 -4
- data/rakefile.rb +49 -3
- data/res/build-tools/db/syncdb.schema +2 -2
- data/res/build-tools/detool.exe +0 -0
- data/res/generators/rhogen.rb +10 -10
- data/res/generators/templates/application/app/helpers/browser_helper.rb +9 -4
- data/res/generators/templates/application/app/index.bb.erb +5 -5
- data/res/generators/templates/application/build.yml +1 -0
- data/res/generators/templates/application/public/css/android.css +10 -8
- data/res/generators/templates/application/public/css/blackberry.css +40 -31
- data/res/generators/templates/application/public/css/iphone.css +4 -4
- data/res/generators/templates/application/public/css/webkit.css +7 -0
- data/res/generators/templates/application/public/css/windows_mobile.css +31 -27
- data/res/generators/templates/application/rhoconfig.txt +2 -2
- data/res/generators/templates/model/edit.bb.erb +2 -2
- data/res/generators/templates/model/index.bb.erb +6 -4
- data/res/generators/templates/model/model.rb +2 -1
- data/res/generators/templates/model/new.bb.erb +2 -2
- data/res/generators/templates/model/show.bb.erb +2 -2
- data/rhobuild.yml +37 -0
- data/rhodes.gemspec +1 -1
- data/spec/framework_spec/app/Account/account.rb +7 -0
- data/spec/framework_spec/app/Case/case.rb +6 -0
- data/spec/framework_spec/app/Customer/customer.rb +6 -0
- data/spec/framework_spec/app/Product/product.rb +9 -0
- data/spec/framework_spec/app/spec/rhom_object_spec.rb +1 -1
- data/spec/framework_spec/app/spec/syncengine_spec.rb +2 -1
- metadata +45 -151
- data/lib/build/manifest/createAppManifest.rb +0 -18
- data/lib/build/tasks/android.rake +0 -317
- data/lib/build/tasks/blackberry.rake +0 -355
- data/lib/build/tasks/common.rake +0 -62
- data/lib/build/tasks/iphone.rake +0 -108
- data/lib/build/tasks/linux.rake +0 -81
- data/lib/build/tasks/rhodes-build.rb +0 -11
- data/lib/build/tasks/rspec.rake +0 -20
- data/lib/build/tasks/symbian.rake +0 -202
- data/lib/build/tasks/wm.rake +0 -166
- data/lib/framework/ServeME.rb +0 -7
- data/platform/bb/build/MANIFEST.MF +0 -12
- data/platform/iphone/Classes/DateTimePicker.h +0 -17
- data/res/generators/templates/application/public/icons/Read me first - license.txt +0 -14
- data/res/generators/templates/application/public/icons/about.png +0 -0
- data/res/generators/templates/application/public/icons/airplane.png +0 -0
- data/res/generators/templates/application/public/icons/baby.png +0 -0
- data/res/generators/templates/application/public/icons/badge.png +0 -0
- data/res/generators/templates/application/public/icons/bandaid.png +0 -0
- data/res/generators/templates/application/public/icons/bar-chart.png +0 -0
- data/res/generators/templates/application/public/icons/battery.png +0 -0
- data/res/generators/templates/application/public/icons/beaker.png +0 -0
- data/res/generators/templates/application/public/icons/beaker2.png +0 -0
- data/res/generators/templates/application/public/icons/beermug.png +0 -0
- data/res/generators/templates/application/public/icons/bird.png +0 -0
- data/res/generators/templates/application/public/icons/book.png +0 -0
- data/res/generators/templates/application/public/icons/bookmark.png +0 -0
- data/res/generators/templates/application/public/icons/brightness.png +0 -0
- data/res/generators/templates/application/public/icons/bug.png +0 -0
- data/res/generators/templates/application/public/icons/cabinet.png +0 -0
- data/res/generators/templates/application/public/icons/calendar.png +0 -0
- data/res/generators/templates/application/public/icons/camera.png +0 -0
- data/res/generators/templates/application/public/icons/changeName.rb +0 -22
- data/res/generators/templates/application/public/icons/chat2.png +0 -0
- data/res/generators/templates/application/public/icons/chicken.png +0 -0
- data/res/generators/templates/application/public/icons/clock.png +0 -0
- data/res/generators/templates/application/public/icons/cloud.png +0 -0
- data/res/generators/templates/application/public/icons/coffee.png +0 -0
- data/res/generators/templates/application/public/icons/compass.png +0 -0
- data/res/generators/templates/application/public/icons/contrast.png +0 -0
- data/res/generators/templates/application/public/icons/dashboard.png +0 -0
- data/res/generators/templates/application/public/icons/display.png +0 -0
- data/res/generators/templates/application/public/icons/dogpaw.png +0 -0
- data/res/generators/templates/application/public/icons/download.png +0 -0
- data/res/generators/templates/application/public/icons/dumbbell.png +0 -0
- data/res/generators/templates/application/public/icons/ekg.png +0 -0
- data/res/generators/templates/application/public/icons/envelope.png +0 -0
- data/res/generators/templates/application/public/icons/equalizer.png +0 -0
- data/res/generators/templates/application/public/icons/eye.png +0 -0
- data/res/generators/templates/application/public/icons/film-roll.png +0 -0
- data/res/generators/templates/application/public/icons/flag.png +0 -0
- data/res/generators/templates/application/public/icons/fork-and-knife.png +0 -0
- data/res/generators/templates/application/public/icons/fuel.png +0 -0
- data/res/generators/templates/application/public/icons/gameplan.png +0 -0
- data/res/generators/templates/application/public/icons/gear.png +0 -0
- data/res/generators/templates/application/public/icons/gear2.png +0 -0
- data/res/generators/templates/application/public/icons/gift.png +0 -0
- data/res/generators/templates/application/public/icons/heart.png +0 -0
- data/res/generators/templates/application/public/icons/house.png +0 -0
- data/res/generators/templates/application/public/icons/inbox.png +0 -0
- data/res/generators/templates/application/public/icons/index-cards.png +0 -0
- data/res/generators/templates/application/public/icons/iphone.png +0 -0
- data/res/generators/templates/application/public/icons/ipod.png +0 -0
- data/res/generators/templates/application/public/icons/key.png +0 -0
- data/res/generators/templates/application/public/icons/lifebuoy.png +0 -0
- data/res/generators/templates/application/public/icons/lightbulb.png +0 -0
- data/res/generators/templates/application/public/icons/line-chart.png +0 -0
- data/res/generators/templates/application/public/icons/location.png +0 -0
- data/res/generators/templates/application/public/icons/lock.png +0 -0
- data/res/generators/templates/application/public/icons/loopback.png +0 -0
- data/res/generators/templates/application/public/icons/magnifying-glass.png +0 -0
- data/res/generators/templates/application/public/icons/map-marker.png +0 -0
- data/res/generators/templates/application/public/icons/map.png +0 -0
- data/res/generators/templates/application/public/icons/medical-bag.png +0 -0
- data/res/generators/templates/application/public/icons/medical.png +0 -0
- data/res/generators/templates/application/public/icons/microphone.png +0 -0
- data/res/generators/templates/application/public/icons/movie1.png +0 -0
- data/res/generators/templates/application/public/icons/movie2.png +0 -0
- data/res/generators/templates/application/public/icons/network.png +0 -0
- data/res/generators/templates/application/public/icons/note.png +0 -0
- data/res/generators/templates/application/public/icons/outlet.png +0 -0
- data/res/generators/templates/application/public/icons/palette.png +0 -0
- data/res/generators/templates/application/public/icons/paperclip.png +0 -0
- data/res/generators/templates/application/public/icons/phone.png +0 -0
- data/res/generators/templates/application/public/icons/photos.png +0 -0
- data/res/generators/templates/application/public/icons/piano.png +0 -0
- data/res/generators/templates/application/public/icons/picture-frame.png +0 -0
- data/res/generators/templates/application/public/icons/pill.png +0 -0
- data/res/generators/templates/application/public/icons/pin.png +0 -0
- data/res/generators/templates/application/public/icons/pinetree.png +0 -0
- data/res/generators/templates/application/public/icons/planet.png +0 -0
- data/res/generators/templates/application/public/icons/puzzle.png +0 -0
- data/res/generators/templates/application/public/icons/radar.png +0 -0
- data/res/generators/templates/application/public/icons/redo.png +0 -0
- data/res/generators/templates/application/public/icons/refresh.png +0 -0
- data/res/generators/templates/application/public/icons/runner.png +0 -0
- data/res/generators/templates/application/public/icons/shoebox.png +0 -0
- data/res/generators/templates/application/public/icons/shopping-bag.png +0 -0
- data/res/generators/templates/application/public/icons/shopping-cart.png +0 -0
- data/res/generators/templates/application/public/icons/shuffle.png +0 -0
- data/res/generators/templates/application/public/icons/signpost.png +0 -0
- data/res/generators/templates/application/public/icons/skull-n-crossbones.png +0 -0
- data/res/generators/templates/application/public/icons/skull.png +0 -0
- data/res/generators/templates/application/public/icons/sliders.png +0 -0
- data/res/generators/templates/application/public/icons/spraycan.png +0 -0
- data/res/generators/templates/application/public/icons/squiggle.png +0 -0
- data/res/generators/templates/application/public/icons/star.png +0 -0
- data/res/generators/templates/application/public/icons/stopwatch.png +0 -0
- data/res/generators/templates/application/public/icons/suitcase.png +0 -0
- data/res/generators/templates/application/public/icons/tag.png +0 -0
- data/res/generators/templates/application/public/icons/tags.png +0 -0
- data/res/generators/templates/application/public/icons/target.png +0 -0
- data/res/generators/templates/application/public/icons/testtube.png +0 -0
- data/res/generators/templates/application/public/icons/thermometer.png +0 -0
- data/res/generators/templates/application/public/icons/toolbox.png +0 -0
- data/res/generators/templates/application/public/icons/trophy.png +0 -0
- data/res/generators/templates/application/public/icons/tshirt.png +0 -0
- data/res/generators/templates/application/public/icons/tv.png +0 -0
- data/res/generators/templates/application/public/icons/umbrella.png +0 -0
- data/res/generators/templates/application/public/icons/walk.png +0 -0
- data/res/generators/templates/application/public/icons/weather.png +0 -0
- data/res/generators/templates/application/public/icons/widescreen.png +0 -0
- data/res/generators/templates/application/public/icons/wineglass.png +0 -0
- data/res/generators/templates/application/public/icons/zap.png +0 -0
- data/res/generators/templates/application/public/js/jquery-1.2.6.min.js +0 -32
- data/res/generators/templates/model/config.rb +0 -3
- data/res/generators/templates/spec/app/spec/webview_spec.rb +0 -5
- data/spec/framework_spec/app/Account/config.rb +0 -59
- data/spec/framework_spec/app/Case/config.rb +0 -3
- data/spec/framework_spec/app/Customer/config.rb +0 -3
- data/spec/framework_spec/app/Product/config.rb +0 -17
@@ -18,6 +18,9 @@ extern "C" int strnicmp( const char *s1, const char *s2, size_t count );
|
|
18
18
|
namespace rho {
|
19
19
|
namespace net {
|
20
20
|
IMPLEMENT_LOGCLASS(CNetRequestImpl,"Net");
|
21
|
+
common::CMutex CNetRequestImpl::m_mxInternet;
|
22
|
+
HINTERNET CNetRequestImpl::m_hInternet;
|
23
|
+
HANDLE CNetRequestImpl::m_hWceConnMgrConnection;
|
21
24
|
|
22
25
|
CNetRequestImpl::CNetRequestImpl(CNetRequest* pParent, const char* method, const String& strUrl,
|
23
26
|
IRhoSession* oSession, Hashtable<String,String>* pHeaders, boolean sslVerifyPeer)
|
@@ -29,65 +32,57 @@ CNetRequestImpl::CNetRequestImpl(CNetRequest* pParent, const char* method, const
|
|
29
32
|
m_pSession = oSession;
|
30
33
|
m_sslVerifyPeer = sslVerifyPeer;
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
m_pszErrFunction = NULL;
|
36
|
+
m_hConnection = NULL;
|
37
|
+
m_hRequest = NULL;
|
38
|
+
memset(&m_uri, 0, sizeof(m_uri) );
|
39
|
+
|
35
40
|
m_strUrl = strUrl;
|
36
41
|
CAtlStringW strUrlW(strUrl.c_str());
|
37
42
|
|
38
43
|
LOG(INFO) + "Method: " + method + ";Url: " + strUrl;
|
39
44
|
do
|
40
45
|
{
|
41
|
-
if ( !URI::isLocalHost(strUrl.c_str())
|
42
|
-
{
|
43
|
-
pszErrFunction = L"SetupInternetConnection";
|
46
|
+
if ( !initConnection(URI::isLocalHost(strUrl.c_str()), strUrlW) )
|
44
47
|
break;
|
45
|
-
}
|
46
|
-
|
47
|
-
hInet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
|
48
|
-
if ( !hInet )
|
49
|
-
{
|
50
|
-
pszErrFunction = L"InternetOpen";
|
51
|
-
break;
|
52
|
-
}
|
53
48
|
|
54
49
|
DWORD dwUrlLength = 1024;
|
55
50
|
CAtlStringW strCanonicalUrlW;
|
56
51
|
if ( !InternetCanonicalizeUrl( strUrlW, strCanonicalUrlW.GetBuffer(dwUrlLength), &dwUrlLength, 0) )
|
57
52
|
{
|
58
|
-
|
53
|
+
m_pszErrFunction = _T("InternetCanonicalizeUrl");
|
59
54
|
break;
|
60
55
|
}
|
61
56
|
strCanonicalUrlW.ReleaseBuffer();
|
62
57
|
|
63
|
-
alloc_url_components( &
|
64
|
-
if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &
|
58
|
+
alloc_url_components( &m_uri, strCanonicalUrlW );
|
59
|
+
if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &m_uri ) )
|
65
60
|
{
|
66
|
-
|
61
|
+
m_pszErrFunction = L"InternetCrackUrl";
|
67
62
|
break;
|
68
63
|
}
|
69
64
|
|
70
|
-
|
65
|
+
m_hConnection = InternetConnect( m_hInternet, m_uri.lpszHostName, m_uri.nPort, _T("anonymous"), NULL,
|
71
66
|
INTERNET_SERVICE_HTTP, 0, 0 );
|
72
|
-
if ( !
|
67
|
+
if ( !m_hConnection )
|
73
68
|
{
|
74
|
-
|
69
|
+
m_pszErrFunction = L"InternetConnect";
|
75
70
|
break;
|
76
71
|
}
|
77
72
|
|
78
|
-
|
79
|
-
|
73
|
+
m_strReqUrlW = m_uri.lpszUrlPath;
|
74
|
+
m_strReqUrlW += m_uri.lpszExtraInfo;
|
80
75
|
DWORD dwFlags = INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_NO_COOKIES;
|
81
|
-
if (
|
76
|
+
if ( m_uri.lpszScheme && wcsicmp(m_uri.lpszScheme,L"https")==0)
|
82
77
|
dwFlags |= INTERNET_FLAG_SECURE;
|
83
78
|
|
84
79
|
if ( !m_sslVerifyPeer )
|
85
80
|
dwFlags |= INTERNET_FLAG_IGNORE_CERT_CN_INVALID|INTERNET_FLAG_IGNORE_CERT_DATE_INVALID;
|
86
81
|
|
87
|
-
|
88
|
-
if ( !
|
82
|
+
m_hRequest = HttpOpenRequest( m_hConnection, CAtlStringW(method), m_strReqUrlW, NULL, NULL, NULL, dwFlags, NULL );
|
83
|
+
if ( !m_hRequest )
|
89
84
|
{
|
90
|
-
|
85
|
+
m_pszErrFunction = L"HttpOpenRequest";
|
91
86
|
break;
|
92
87
|
}
|
93
88
|
|
@@ -99,8 +94,8 @@ CNetRequestImpl::CNetRequestImpl(CNetRequest* pParent, const char* method, const
|
|
99
94
|
{
|
100
95
|
String strHeader = "Cookie: " + strSession + "\r\n";
|
101
96
|
|
102
|
-
if ( !HttpAddRequestHeaders(
|
103
|
-
|
97
|
+
if ( !HttpAddRequestHeaders( m_hRequest, common::convertToStringW(strHeader).c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
|
98
|
+
m_pszErrFunction = L"HttpAddRequestHeaders";
|
104
99
|
}
|
105
100
|
}
|
106
101
|
|
@@ -118,11 +113,11 @@ boolean CNetRequestImpl::checkSslCertError()
|
|
118
113
|
{
|
119
114
|
DWORD dwFlag;
|
120
115
|
DWORD dwBuffLen = sizeof(dwFlag);
|
121
|
-
InternetQueryOption (
|
116
|
+
InternetQueryOption (m_hRequest, INTERNET_OPTION_SECURITY_FLAGS,(LPVOID)&dwFlag, &dwBuffLen);
|
122
117
|
dwFlag |= (SECURITY_FLAG_IGNORE_UNKNOWN_CA
|
123
118
|
| SECURITY_FLAG_IGNORE_CERT_CN_INVALID
|
124
119
|
| SECURITY_FLAG_IGNORE_CERT_DATE_INVALID );
|
125
|
-
InternetSetOption (
|
120
|
+
InternetSetOption (m_hRequest, INTERNET_OPTION_SECURITY_FLAGS, &dwFlag, sizeof (dwFlag) );
|
126
121
|
/*
|
127
122
|
INTERNET_CERTIFICATE_INFO sInfo;
|
128
123
|
DWORD dwSize = sizeof(sInfo);
|
@@ -162,26 +157,26 @@ CNetResponseImpl* CNetRequestImpl::sendString(const String& strBody)
|
|
162
157
|
strHeaders += getBodyContentType().c_str();
|
163
158
|
strHeaders += L"\r\n";
|
164
159
|
|
165
|
-
if ( !HttpAddRequestHeaders(
|
160
|
+
if ( !HttpAddRequestHeaders( m_hRequest, strHeaders, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
|
166
161
|
{
|
167
|
-
|
162
|
+
m_pszErrFunction = L"HttpAddRequestHeaders";
|
168
163
|
break;
|
169
164
|
}
|
170
165
|
}
|
171
166
|
writeHeaders(m_pHeaders);
|
172
167
|
|
173
|
-
if ( !HttpSendRequest(
|
168
|
+
if ( !HttpSendRequest( m_hRequest, NULL, 0, const_cast<char*>(strBody.c_str()), strBody.length() ) )
|
174
169
|
{
|
175
170
|
if (checkSslCertError())
|
176
171
|
{
|
177
|
-
if ( !HttpSendRequest(
|
172
|
+
if ( !HttpSendRequest( m_hRequest, NULL, 0, const_cast<char*>(strBody.c_str()), strBody.length() ) )
|
178
173
|
{
|
179
|
-
|
174
|
+
m_pszErrFunction = L"HttpSendRequest";
|
180
175
|
break;
|
181
176
|
}
|
182
177
|
}else
|
183
178
|
{
|
184
|
-
|
179
|
+
m_pszErrFunction = L"HttpSendRequest";
|
185
180
|
break;
|
186
181
|
}
|
187
182
|
}
|
@@ -190,7 +185,7 @@ CNetResponseImpl* CNetRequestImpl::sendString(const String& strBody)
|
|
190
185
|
if ( isError() )
|
191
186
|
break;
|
192
187
|
|
193
|
-
readInetFile(
|
188
|
+
readInetFile(m_hRequest,pNetResp);
|
194
189
|
}while(0);
|
195
190
|
|
196
191
|
return pNetResp;
|
@@ -205,9 +200,9 @@ void CNetRequestImpl::writeHeaders(Hashtable<String,String>* pHeaders)
|
|
205
200
|
for ( Hashtable<String,String>::iterator it = pHeaders->begin(); it != pHeaders->end(); ++it )
|
206
201
|
strHeaders += it->first + ":" + it->second + "\r\n";
|
207
202
|
|
208
|
-
if ( !HttpAddRequestHeaders(
|
203
|
+
if ( !HttpAddRequestHeaders( m_hRequest, common::convertToStringW(strHeaders).c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
|
209
204
|
{
|
210
|
-
|
205
|
+
m_pszErrFunction = L"HttpAddRequestHeaders";
|
211
206
|
return;
|
212
207
|
}
|
213
208
|
}
|
@@ -220,18 +215,18 @@ boolean CNetRequestImpl::readHeaders(Hashtable<String,String>& oHeaders)
|
|
220
215
|
CAtlStringW strHeaders;
|
221
216
|
DWORD dwLen = 0;
|
222
217
|
DWORD nIndex = 0;
|
223
|
-
if( !HttpQueryInfo(
|
218
|
+
if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, null, &dwLen, &nIndex) )
|
224
219
|
{
|
225
220
|
DWORD dwErr = ::GetLastError();
|
226
221
|
if ( dwErr != ERROR_INSUFFICIENT_BUFFER )
|
227
222
|
{
|
228
|
-
|
223
|
+
m_pszErrFunction = L"HttpQueryInfo";
|
229
224
|
return false;
|
230
225
|
}
|
231
226
|
}
|
232
|
-
if( !HttpQueryInfo(
|
227
|
+
if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, strHeaders.GetBuffer(dwLen), &dwLen, &nIndex) )
|
233
228
|
{
|
234
|
-
|
229
|
+
m_pszErrFunction = L"HttpQueryInfo";
|
235
230
|
return false;
|
236
231
|
}
|
237
232
|
strHeaders.ReleaseBuffer();
|
@@ -264,7 +259,7 @@ String CNetRequestImpl::makeClientCookie()
|
|
264
259
|
{
|
265
260
|
CAtlStringW strCookie;
|
266
261
|
DWORD dwLen = 0;
|
267
|
-
if( !HttpQueryInfo(
|
262
|
+
if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_SET_COOKIE, null, &dwLen, &nIndex) )
|
268
263
|
{
|
269
264
|
DWORD dwErr = ::GetLastError();
|
270
265
|
if ( dwErr == ERROR_HTTP_HEADER_NOT_FOUND )
|
@@ -272,20 +267,20 @@ String CNetRequestImpl::makeClientCookie()
|
|
272
267
|
|
273
268
|
if ( dwErr != ERROR_INSUFFICIENT_BUFFER )
|
274
269
|
{
|
275
|
-
|
270
|
+
m_pszErrFunction = L"HttpQueryInfo";
|
276
271
|
break;
|
277
272
|
}
|
278
273
|
}
|
279
|
-
if( !HttpQueryInfo(
|
274
|
+
if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_SET_COOKIE, strCookie.GetBuffer(dwLen), &dwLen, &nIndex) )
|
280
275
|
{
|
281
|
-
|
276
|
+
m_pszErrFunction = L"HttpQueryInfo";
|
282
277
|
break;
|
283
278
|
}
|
284
279
|
strCookie.ReleaseBuffer();
|
285
280
|
|
286
281
|
URI::parseCookie(common::convertToStringA(strCookie.GetString()).c_str(), cookie);
|
287
282
|
}
|
288
|
-
if (
|
283
|
+
if (m_pszErrFunction)
|
289
284
|
return "";
|
290
285
|
|
291
286
|
// if ( cookie.strAuth.length() > 0 || cookie.strSession.length() >0 )
|
@@ -300,9 +295,9 @@ void CNetRequestImpl::readResponse(CNetResponseImpl* pNetResp)
|
|
300
295
|
wchar_t szHttpRes[10];
|
301
296
|
DWORD nIndex = 0;
|
302
297
|
|
303
|
-
if( !HttpQueryInfo(
|
298
|
+
if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_STATUS_CODE, szHttpRes, &dwLen, &nIndex) )
|
304
299
|
{
|
305
|
-
|
300
|
+
m_pszErrFunction = L"HttpQueryInfo";
|
306
301
|
return;
|
307
302
|
}
|
308
303
|
int nCode = _wtoi(szHttpRes);
|
@@ -333,7 +328,7 @@ void CNetRequestImpl::readResponse(CNetResponseImpl* pNetResp)
|
|
333
328
|
CNetResponseImpl* CNetRequestImpl::downloadFile(common::CRhoFile& oFile)
|
334
329
|
{
|
335
330
|
CNetResponseImpl* pNetResp = new CNetResponseImpl;
|
336
|
-
const int nDownloadBufferSize = 1024*
|
331
|
+
const int nDownloadBufferSize = 1024*100;
|
337
332
|
char* pDownloadBuffer = 0;
|
338
333
|
|
339
334
|
do
|
@@ -351,25 +346,25 @@ CNetResponseImpl* CNetRequestImpl::downloadFile(common::CRhoFile& oFile)
|
|
351
346
|
//strHeaders += common::convertToStringW(oFile.size()+30068032).c_str();
|
352
347
|
strHeaders += "\r\n";
|
353
348
|
|
354
|
-
if ( !HttpAddRequestHeaders(
|
349
|
+
if ( !HttpAddRequestHeaders( m_hRequest, strHeaders, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
|
355
350
|
{
|
356
|
-
|
351
|
+
m_pszErrFunction = L"HttpAddRequestHeaders";
|
357
352
|
break;
|
358
353
|
}
|
359
354
|
}
|
360
355
|
|
361
|
-
if ( !HttpSendRequest(
|
356
|
+
if ( !HttpSendRequest( m_hRequest, NULL, 0, NULL, 0 ) )
|
362
357
|
{
|
363
358
|
if (checkSslCertError())
|
364
359
|
{
|
365
|
-
if ( !HttpSendRequest(
|
360
|
+
if ( !HttpSendRequest( m_hRequest, NULL, 0, NULL, 0 ) )
|
366
361
|
{
|
367
|
-
|
362
|
+
m_pszErrFunction = L"HttpSendRequest";
|
368
363
|
break;
|
369
364
|
}
|
370
365
|
}else
|
371
366
|
{
|
372
|
-
|
367
|
+
m_pszErrFunction = L"HttpSendRequest";
|
373
368
|
break;
|
374
369
|
}
|
375
370
|
}
|
@@ -387,7 +382,7 @@ CNetResponseImpl* CNetRequestImpl::downloadFile(common::CRhoFile& oFile)
|
|
387
382
|
if (!pDownloadBuffer)
|
388
383
|
pDownloadBuffer = new char[nDownloadBufferSize];
|
389
384
|
|
390
|
-
readInetFile(
|
385
|
+
readInetFile(m_hRequest,pNetResp, &oFile, pDownloadBuffer, nDownloadBufferSize);
|
391
386
|
|
392
387
|
}while(0);
|
393
388
|
|
@@ -469,9 +464,9 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
|
|
469
464
|
if ( isError() )
|
470
465
|
break;
|
471
466
|
|
472
|
-
if ( !HttpAddRequestHeaders(
|
467
|
+
if ( !HttpAddRequestHeaders( m_hRequest, szMultipartContType, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
|
473
468
|
{
|
474
|
-
|
469
|
+
m_pszErrFunction = L"HttpAddRequestHeaders";
|
475
470
|
break;
|
476
471
|
}
|
477
472
|
|
@@ -480,18 +475,18 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
|
|
480
475
|
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS ); // Must be set or error will occur
|
481
476
|
BufferIn.dwBufferTotal = processMultipartItems( arItems );
|
482
477
|
|
483
|
-
if(!HttpSendRequestEx(
|
478
|
+
if(!HttpSendRequestEx( m_hRequest, &BufferIn, NULL, 0, 0))
|
484
479
|
{
|
485
480
|
if (checkSslCertError())
|
486
481
|
{
|
487
|
-
if(!HttpSendRequestEx(
|
482
|
+
if(!HttpSendRequestEx( m_hRequest, &BufferIn, NULL, 0, 0))
|
488
483
|
{
|
489
|
-
|
484
|
+
m_pszErrFunction = L"HttpSendRequestEx";
|
490
485
|
break;
|
491
486
|
}
|
492
487
|
}else
|
493
488
|
{
|
494
|
-
|
489
|
+
m_pszErrFunction = L"HttpSendRequestEx";
|
495
490
|
break;
|
496
491
|
}
|
497
492
|
}
|
@@ -506,14 +501,14 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
|
|
506
501
|
common::CRhoFile oFile;
|
507
502
|
if ( !oFile.open(oItem.m_strFilePath.c_str(),common::CRhoFile::OpenReadOnly) )
|
508
503
|
{
|
509
|
-
|
504
|
+
m_pszErrFunction = L"InternetWriteFile";
|
510
505
|
return pNetResp;
|
511
506
|
}
|
512
507
|
common::InputStream* bodyStream = oFile.getInputStream();
|
513
508
|
|
514
509
|
if ( !internetWriteHeader( oItem.m_strDataPrefix.c_str(), "", "") )
|
515
510
|
{
|
516
|
-
|
511
|
+
m_pszErrFunction = L"InternetWriteFile";
|
517
512
|
return pNetResp;
|
518
513
|
}
|
519
514
|
|
@@ -529,9 +524,9 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
|
|
529
524
|
nReaded = bodyStream->read(pBuf,0,dwBufSize);
|
530
525
|
if ( nReaded > 0 )
|
531
526
|
{
|
532
|
-
if ( !InternetWriteFile(
|
527
|
+
if ( !InternetWriteFile( m_hRequest, pBuf, nReaded, &dwBytesWritten) )
|
533
528
|
{
|
534
|
-
|
529
|
+
m_pszErrFunction = L"InternetWriteFile";
|
535
530
|
return pNetResp;
|
536
531
|
}
|
537
532
|
}
|
@@ -544,7 +539,7 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
|
|
544
539
|
{
|
545
540
|
if ( !internetWriteHeader( oItem.m_strDataPrefix.c_str(), oItem.m_strBody.c_str(), "") )
|
546
541
|
{
|
547
|
-
|
542
|
+
m_pszErrFunction = L"InternetWriteFile";
|
548
543
|
return pNetResp;
|
549
544
|
}
|
550
545
|
}
|
@@ -553,13 +548,13 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
|
|
553
548
|
|
554
549
|
if ( !internetWriteHeader( "", "", szMultipartPostfix) )
|
555
550
|
{
|
556
|
-
|
551
|
+
m_pszErrFunction = L"InternetWriteFile";
|
557
552
|
return pNetResp;
|
558
553
|
}
|
559
554
|
|
560
|
-
if ( !HttpEndRequest(
|
555
|
+
if ( !HttpEndRequest(m_hRequest, NULL, 0, 0) )
|
561
556
|
{
|
562
|
-
|
557
|
+
m_pszErrFunction = L"HttpEndRequest";
|
563
558
|
break;
|
564
559
|
}
|
565
560
|
|
@@ -570,7 +565,7 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
|
|
570
565
|
if ( isError() )
|
571
566
|
break;
|
572
567
|
|
573
|
-
readInetFile(
|
568
|
+
readInetFile(m_hRequest,pNetResp);
|
574
569
|
|
575
570
|
}while(0);
|
576
571
|
|
@@ -580,13 +575,13 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
|
|
580
575
|
bool CNetRequestImpl::internetWriteHeader( const char* szPrefix, const char* szBody, const char* szPrefixEnd)
|
581
576
|
{
|
582
577
|
DWORD dwBytesWritten = 0;
|
583
|
-
if ( szPrefix && *szPrefix && !InternetWriteFile(
|
578
|
+
if ( szPrefix && *szPrefix && !InternetWriteFile( m_hRequest, szPrefix, strlen(szPrefix), &dwBytesWritten) )
|
584
579
|
return false;
|
585
580
|
|
586
|
-
if ( szBody && *szBody && !InternetWriteFile(
|
581
|
+
if ( szBody && *szBody && !InternetWriteFile( m_hRequest, szBody, strlen(szBody), &dwBytesWritten) )
|
587
582
|
return false;
|
588
583
|
|
589
|
-
if ( szPrefixEnd && *szPrefixEnd && !InternetWriteFile(
|
584
|
+
if ( szPrefixEnd && *szPrefixEnd && !InternetWriteFile( m_hRequest, szPrefixEnd, strlen(szPrefixEnd), &dwBytesWritten) )
|
590
585
|
return false;
|
591
586
|
|
592
587
|
return true;
|
@@ -596,8 +591,8 @@ void CNetRequestImpl::cancel()
|
|
596
591
|
{
|
597
592
|
m_bCancel = true;
|
598
593
|
|
599
|
-
if (
|
600
|
-
InternetCloseHandle(
|
594
|
+
if ( m_hRequest )
|
595
|
+
InternetCloseHandle(m_hRequest);
|
601
596
|
/* if ( hConnection )
|
602
597
|
InternetCloseHandle(hConnection);
|
603
598
|
if ( hInet )
|
@@ -610,23 +605,23 @@ void CNetRequestImpl::cancel()
|
|
610
605
|
|
611
606
|
void CNetRequestImpl::close()
|
612
607
|
{
|
613
|
-
if (!m_bCancel &&
|
614
|
-
ErrorMessage(
|
608
|
+
if (!m_bCancel && m_pszErrFunction)
|
609
|
+
ErrorMessage(m_pszErrFunction);
|
615
610
|
|
616
|
-
free_url_components(&
|
611
|
+
free_url_components(&m_uri);
|
617
612
|
|
618
|
-
if (
|
619
|
-
InternetCloseHandle(
|
620
|
-
if (
|
621
|
-
InternetCloseHandle(
|
622
|
-
if ( hInet )
|
623
|
-
InternetCloseHandle(hInet);
|
613
|
+
if ( m_hRequest )
|
614
|
+
InternetCloseHandle(m_hRequest);
|
615
|
+
if ( m_hConnection )
|
616
|
+
InternetCloseHandle(m_hConnection);
|
617
|
+
// if ( hInet )
|
618
|
+
// InternetCloseHandle(hInet);
|
624
619
|
|
625
|
-
memset(&
|
620
|
+
memset(&m_uri, 0, sizeof(m_uri));
|
626
621
|
|
627
|
-
|
628
|
-
|
629
|
-
hInet = 0;
|
622
|
+
m_hRequest = 0;
|
623
|
+
m_hConnection = 0;
|
624
|
+
// hInet = 0;
|
630
625
|
}
|
631
626
|
|
632
627
|
CNetRequestImpl::~CNetRequestImpl()
|
@@ -644,7 +639,7 @@ void CNetRequestImpl::readInetFile( HINTERNET hRequest, CNetResponseImpl* pNetRe
|
|
644
639
|
if (!pBuf)
|
645
640
|
{
|
646
641
|
if ( dwBufSize==0)
|
647
|
-
dwBufSize=1024*
|
642
|
+
dwBufSize=1024*50;
|
648
643
|
|
649
644
|
pBuf = (char*)malloc(dwBufSize);
|
650
645
|
pBufToFree = pBuf;
|
@@ -660,7 +655,7 @@ void CNetRequestImpl::readInetFile( HINTERNET hRequest, CNetResponseImpl* pNetRe
|
|
660
655
|
bRead = InternetReadFile(hRequest, pBuf, dwBufSize, &dwBytesRead);
|
661
656
|
if ( !bRead )
|
662
657
|
{
|
663
|
-
|
658
|
+
m_pszErrFunction = L"InternetReadFile";
|
664
659
|
pNetResp->setResponseCode(408);
|
665
660
|
break;
|
666
661
|
}
|
@@ -764,27 +759,66 @@ void CNetRequestImpl::free_url_components(URL_COMPONENTS *uri)
|
|
764
759
|
free(uri->lpszExtraInfo);
|
765
760
|
}
|
766
761
|
|
762
|
+
bool CNetRequestImpl::initConnection(boolean bLocalHost, LPCTSTR url)
|
763
|
+
{
|
764
|
+
common::CMutexLock lock(m_mxInternet);
|
765
|
+
|
766
|
+
if (!bLocalHost)
|
767
|
+
{
|
768
|
+
if ( !SetupInternetConnection(url) )
|
769
|
+
return false;
|
770
|
+
}
|
771
|
+
|
772
|
+
if (m_hInternet)
|
773
|
+
return true;
|
774
|
+
|
775
|
+
m_hInternet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
|
776
|
+
if ( !m_hInternet )
|
777
|
+
{
|
778
|
+
m_pszErrFunction = L"InternetOpen";
|
779
|
+
return false;
|
780
|
+
}
|
781
|
+
|
782
|
+
return true;
|
783
|
+
}
|
784
|
+
|
785
|
+
/*static*/void CNetRequestImpl::deinitConnection()
|
786
|
+
{
|
787
|
+
common::CMutexLock lock(m_mxInternet);
|
788
|
+
|
789
|
+
if (m_hInternet)
|
790
|
+
InternetCloseHandle(m_hInternet);
|
791
|
+
m_hInternet = NULL;
|
792
|
+
|
793
|
+
#if defined (_WIN32_WCE)
|
794
|
+
if ( m_hWceConnMgrConnection )
|
795
|
+
ConnMgrReleaseConnection(m_hWceConnMgrConnection, FALSE);
|
796
|
+
|
797
|
+
m_hWceConnMgrConnection = NULL;
|
798
|
+
#endif //_WIN32_WCE
|
799
|
+
|
800
|
+
}
|
801
|
+
|
767
802
|
bool CNetRequestImpl::SetupInternetConnection(LPCTSTR url)
|
768
803
|
{
|
769
804
|
#if defined (_WIN32_WCE)
|
770
805
|
int iNetwork;
|
771
806
|
HRESULT hResult = E_FAIL;
|
772
807
|
DWORD dwStatus;
|
773
|
-
static HANDLE hConnection = NULL;
|
774
808
|
|
775
809
|
// cleanup the old connection
|
776
|
-
if(NULL !=
|
810
|
+
if(NULL != m_hWceConnMgrConnection)
|
777
811
|
{
|
778
|
-
hResult = ConnMgrConnectionStatus(
|
812
|
+
hResult = ConnMgrConnectionStatus( m_hWceConnMgrConnection, &dwStatus );
|
779
813
|
if( SUCCEEDED(hResult) )
|
780
814
|
{
|
781
815
|
LOG(INFO) + "Internet connection exist, use it";
|
782
816
|
if( dwStatus & CONNMGR_STATUS_CONNECTED )
|
783
817
|
return true;
|
784
818
|
}
|
785
|
-
ConnMgrReleaseConnection(
|
819
|
+
ConnMgrReleaseConnection(m_hWceConnMgrConnection, FALSE);
|
786
820
|
LOG(INFO) + "Internet connection droped, open new one";
|
787
|
-
|
821
|
+
m_hWceConnMgrConnection = NULL;
|
788
822
|
}
|
789
823
|
|
790
824
|
// get the right network to connect to
|
@@ -810,17 +844,17 @@ bool CNetRequestImpl::SetupInternetConnection(LPCTSTR url)
|
|
810
844
|
#endif
|
811
845
|
ConnInfo.guidDestNet = pguid;
|
812
846
|
|
813
|
-
hResult = ConnMgrEstablishConnection(&ConnInfo, &
|
847
|
+
hResult = ConnMgrEstablishConnection(&ConnInfo, &m_hWceConnMgrConnection);
|
814
848
|
|
815
849
|
// check to see if the attempt failed
|
816
850
|
int count = 0;
|
817
851
|
while(SUCCEEDED(hResult) && count++ < 60 )
|
818
852
|
{
|
819
853
|
LOG(INFO) + "Wait for connect (" + count + ")";
|
820
|
-
DWORD dwResult = WaitForSingleObject(
|
854
|
+
DWORD dwResult = WaitForSingleObject(m_hWceConnMgrConnection, 1000);
|
821
855
|
if (dwResult == (WAIT_OBJECT_0))
|
822
856
|
{
|
823
|
-
hResult=ConnMgrConnectionStatus(
|
857
|
+
hResult=ConnMgrConnectionStatus(m_hWceConnMgrConnection,&dwStatus);
|
824
858
|
if( SUCCEEDED(hResult) )
|
825
859
|
{
|
826
860
|
if( dwStatus & CONNMGR_STATUS_CONNECTED )
|
@@ -65,10 +65,15 @@ class CNetRequestImpl
|
|
65
65
|
{
|
66
66
|
DEFINE_LOGCLASS;
|
67
67
|
|
68
|
-
|
69
|
-
HINTERNET
|
70
|
-
|
71
|
-
|
68
|
+
static common::CMutex m_mxInternet;
|
69
|
+
static HINTERNET m_hInternet;
|
70
|
+
static HANDLE m_hWceConnMgrConnection;
|
71
|
+
HINTERNET m_hConnection, m_hRequest;
|
72
|
+
|
73
|
+
LPCTSTR m_pszErrFunction;
|
74
|
+
|
75
|
+
URL_COMPONENTS m_uri;
|
76
|
+
CAtlStringW m_strReqUrlW;
|
72
77
|
String m_strUrl;
|
73
78
|
CNetRequest* m_pParent;
|
74
79
|
Hashtable<String,String>* m_pHeaders;
|
@@ -83,13 +88,14 @@ public :
|
|
83
88
|
|
84
89
|
void close();
|
85
90
|
void cancel();
|
86
|
-
bool isError(){ return
|
91
|
+
bool isError(){ return m_pszErrFunction!= null; }
|
87
92
|
CNetResponseImpl* sendString(const String& strBody);
|
88
93
|
|
89
94
|
CNetResponseImpl* sendMultipartData(VectorPtr<CMultipartItem*>& arItems);
|
90
95
|
|
91
96
|
CNetResponseImpl* downloadFile(common::CRhoFile& oFile);
|
92
97
|
|
98
|
+
static void deinitConnection();
|
93
99
|
private:
|
94
100
|
String makeClientCookie();
|
95
101
|
|
@@ -109,6 +115,7 @@ private:
|
|
109
115
|
|
110
116
|
int processMultipartItems( VectorPtr<CMultipartItem*>& arItems );
|
111
117
|
|
118
|
+
bool initConnection(boolean bLocalHost, LPCTSTR url);
|
112
119
|
};
|
113
120
|
|
114
121
|
}
|
@@ -257,6 +257,16 @@ static double get_screen_ppi_y()
|
|
257
257
|
return ret;
|
258
258
|
}
|
259
259
|
|
260
|
+
VALUE rho_sys_get_locale()
|
261
|
+
{
|
262
|
+
wchar_t szLang[20];
|
263
|
+
int nRes = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SABBREVLANGNAME , szLang, sizeof(szLang)/sizeof(szLang[0]));
|
264
|
+
szLang[2] = 0;
|
265
|
+
wcslwr(szLang);
|
266
|
+
|
267
|
+
return rho_ruby_create_string(convertToStringA(szLang).c_str());
|
268
|
+
}
|
269
|
+
|
260
270
|
int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
|
261
271
|
{
|
262
272
|
if (strcasecmp("has_camera",szPropName) == 0)
|
@@ -271,10 +281,24 @@ int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
|
|
271
281
|
if (strcasecmp("ppi_y",szPropName) == 0)
|
272
282
|
{*resValue = rho_ruby_create_double(get_screen_ppi_y()); return 1; }
|
273
283
|
|
284
|
+
if (strcasecmp("locale",szPropName) == 0)
|
285
|
+
{*resValue = rho_sys_get_locale(); return 1;}
|
286
|
+
|
287
|
+
if (strcasecmp("country",szPropName) == 0)
|
288
|
+
{
|
289
|
+
wchar_t szCountry[20];
|
290
|
+
int nRes = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SISO3166CTRYNAME , szCountry, sizeof(szCountry)/sizeof(szCountry[0]));
|
291
|
+
szCountry[2] = 0;
|
292
|
+
|
293
|
+
*resValue = rho_ruby_create_string(convertToStringA(szCountry).c_str());
|
294
|
+
return 1;
|
295
|
+
}
|
296
|
+
|
274
297
|
if (strcasecmp("device_name",szPropName) == 0)
|
275
298
|
{
|
276
299
|
#ifdef OS_WINDOWS
|
277
300
|
*resValue = rho_ruby_create_string("Win32");
|
301
|
+
return 1;
|
278
302
|
#else
|
279
303
|
HKEY hKey;
|
280
304
|
if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Ident"),
|
@@ -315,16 +339,6 @@ int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
|
|
315
339
|
return 0;
|
316
340
|
}
|
317
341
|
|
318
|
-
VALUE rho_sys_get_locale()
|
319
|
-
{
|
320
|
-
wchar_t szLang[20];
|
321
|
-
int nRes = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SABBREVLANGNAME , szLang, 20);
|
322
|
-
szLang[2] = 0;
|
323
|
-
wcslwr(szLang);
|
324
|
-
|
325
|
-
return rho_ruby_create_string(convertToStringA(szLang).c_str());
|
326
|
-
}
|
327
|
-
|
328
342
|
int rho_sys_get_screen_width()
|
329
343
|
{
|
330
344
|
#ifdef OS_WINCE
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#include "stdafx.h"
|
2
|
+
#include <wininet.h>
|
2
3
|
|
3
4
|
#include "ruby/ext/rho/rhoruby.h"
|
4
5
|
#include "rubyext/WebView.h"
|
@@ -57,6 +58,11 @@ void rho_webview_full_screen_mode(int enable)
|
|
57
58
|
::PostMessage( getMainWnd(), WM_COMMAND, ID_FULLSCREEN, (LPARAM)enable );
|
58
59
|
}
|
59
60
|
|
61
|
+
void rho_webview_set_cookie(const char *url, const char *cookie)
|
62
|
+
{
|
63
|
+
::InternetSetCookieA(url, NULL, cookie);
|
64
|
+
}
|
65
|
+
|
60
66
|
}
|
61
67
|
|
62
68
|
|