rhodes 3.3.2 → 3.3.3.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Manifest.txt +4 -0
- data/Rakefile +2 -2
- data/doc/device-caps.txt +2 -2
- data/doc/rhodes-api.txt +0 -3
- data/installer/rhostudio-moto.nsi +14 -48
- data/installer/rhostudio.nsi +12 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +167 -46
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +15 -15
- data/platform/android/build/android.rake +36 -24
- data/platform/iphone/Classes/MapView/GoogleGeocoder.h +2 -1
- data/platform/iphone/Classes/MapView/GoogleGeocoder.m +44 -6
- data/platform/iphone/Classes/MapView/MapViewController.m +10 -1
- data/platform/shared/common/ExtManager.cpp +103 -0
- data/platform/shared/common/ExtManager.h +101 -0
- data/platform/shared/common/RhodesApp.cpp +3 -2
- data/platform/shared/common/RhodesApp.h +3 -0
- data/platform/shared/common/map/GeocodingMapEngine.cpp +24 -1
- data/platform/shared/common/map/GeocodingMapEngine.h +3 -0
- data/platform/shared/logging/RhoLogConf.cpp +2 -1
- data/platform/shared/net/HttpServer.cpp +1 -1
- data/platform/shared/ruby/ext/rho/rhoruby.c +6 -0
- data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
- data/platform/wm/rhodes/DateTimePicker.cpp +38 -8
- data/platform/wm/rhodes/DateTimePicker.h +4 -0
- data/platform/wm/rhodes/LogOptionsDlg.cpp +16 -0
- data/platform/wm/rhodes/LogOptionsDlg.h +3 -2
- data/platform/wm/rhodes/LogView.cpp +21 -1
- data/platform/wm/rhodes/LogView.h +3 -1
- data/platform/wm/rhodes/MainWindow.cpp +1 -2
- data/platform/wm/rhodes/MapView/MapViewManager.cpp +16 -2
- data/platform/wm/rhodes/MapView/MapViewManager.h +2 -0
- data/platform/wm/rhodes/Rhodes.cpp +2 -1
- data/platform/wm/rhodes/Rhodes.rc +7 -6
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.cpp +303 -147
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.h +22 -16
- data/platform/wm/rhoelements.sln +3 -3
- data/platform/wp7/RhoRubyLib/common/RhoFile.cs +16 -0
- data/platform/wp7/RhoRubyLib/net/HttpServer.cs +5 -5
- data/platform/wp7/RhoRubyLib/views/RhoView.xaml +1 -1
- data/platform/wp7/RhoRubyLib/views/RhoView.xaml.cs +36 -3
- data/rakefile.rb +2 -2
- data/res/generators/rhogen.rb +5 -0
- data/res/generators/templates/application/app/layout.erb +6 -2
- data/res/generators/templates/application/public/js/jquery-wp7-patch.js +149 -0
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Montana.sln +29 -7
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/Montana.vcproj +316 -0
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/wm/montana.vsprops +15 -0
- data/version +1 -1
- metadata +11 -5
@@ -36,13 +36,11 @@ import com.rhomobile.rhodes.Logger;
|
|
36
36
|
import com.rhomobile.rhodes.RhodesActivity;
|
37
37
|
import com.rhomobile.rhodes.RhodesApplication;
|
38
38
|
import com.rhomobile.rhodes.util.PerformOnUiThread;
|
39
|
-
import com.rhomobile.rhodes.util.Utils;
|
40
39
|
import com.rhomobile.rhodes.webview.GoogleWebView;
|
41
40
|
import com.rhomobile.rhodes.webview.WebView;
|
42
41
|
|
43
|
-
import android.
|
42
|
+
import android.content.Context;
|
44
43
|
import android.content.res.AssetManager;
|
45
|
-
import android.util.Log;
|
46
44
|
import android.view.View;
|
47
45
|
import android.widget.FrameLayout;
|
48
46
|
import android.widget.LinearLayout;
|
@@ -107,15 +105,17 @@ public class SplashScreen implements MainView {
|
|
107
105
|
// Now create WebView and load appropriate content there
|
108
106
|
WebView view = null;//new GoogleWebView(context);
|
109
107
|
if (Capabilities.WEBKIT_BROWSER_ENABLED) {
|
108
|
+
Logger.D(TAG, "Creating Motorola WebKIT view");
|
110
109
|
try {
|
111
110
|
Class<? extends WebView> viewClass = (Class<? extends WebView>)Class.forName("com.rhomobile.rhodes.webview.EkiohWebView");
|
112
|
-
Constructor<? extends WebView> viewCtor = viewClass.getConstructor(
|
113
|
-
view = viewCtor.newInstance(context);
|
111
|
+
Constructor<? extends WebView> viewCtor = viewClass.getConstructor(Context.class, Runnable.class);
|
112
|
+
view = viewCtor.newInstance(context, RhodesApplication.AppState.AppStarted.addObserver("MotorolaStartEngineObserver", true));
|
114
113
|
} catch (Throwable e) {
|
115
114
|
Logger.E(TAG, e);
|
116
115
|
RhodesApplication.stop();
|
117
116
|
}
|
118
117
|
} else {
|
118
|
+
Logger.D(TAG, "Creating Google web view");
|
119
119
|
final GoogleWebView googleWebView = new GoogleWebView(context);
|
120
120
|
view = googleWebView;
|
121
121
|
RhodesApplication.runWhen(RhodesApplication.AppState.AppStarted, new RhodesApplication.StateHandler(true) {
|
@@ -125,18 +125,18 @@ public class SplashScreen implements MainView {
|
|
125
125
|
googleWebView.applyWebSettings();
|
126
126
|
}
|
127
127
|
});
|
128
|
+
switch (type) {
|
129
|
+
case 0:
|
130
|
+
view.loadDataWithBaseURL("file:///android_asset/", "<html><body style=\"margin:0px\"><img src=\""+ fn[type] + "\" height=\"100%\" width=\"100%\" border=\"0\"/></body></html>", "text/html", "utf-8", null);
|
131
|
+
break;
|
132
|
+
case 1:
|
133
|
+
view.loadUrl("file:///android_asset/" + fn[type]);
|
134
|
+
break;
|
135
|
+
default:
|
136
|
+
view.loadData("<html><title>Loading</title><body text='white' bgcolor='black'>Loading...</body></html>", "text/html", "utf-8");
|
137
|
+
}
|
128
138
|
}
|
129
139
|
|
130
|
-
switch (type) {
|
131
|
-
case 0:
|
132
|
-
view.loadDataWithBaseURL("file:///android_asset/", "<html><body style=\"margin:0px\"><img src=\""+ fn[type] + "\" height=\"100%\" width=\"100%\" border=\"0\"/></body></html>", "text/html", "utf-8", null);
|
133
|
-
break;
|
134
|
-
case 1:
|
135
|
-
view.loadUrl("file:///android_asset/" + fn[type]);
|
136
|
-
break;
|
137
|
-
default:
|
138
|
-
view.loadData("<html><title>Loading</title><body text='white' bgcolor='black'>Loading...</body></html>", "text/html", "utf-8");
|
139
|
-
}
|
140
140
|
|
141
141
|
return view;
|
142
142
|
}
|
@@ -1520,6 +1520,9 @@ namespace "package" do
|
|
1520
1520
|
Dir.glob($extensionsdir + "/lib*.so").each do |lib|
|
1521
1521
|
cp_r lib, File.join($tmpdir, "lib/armeabi")
|
1522
1522
|
end
|
1523
|
+
Dir.glob($extensionsdir + '/noautoload/lib*.so').each do |lib|
|
1524
|
+
cp_r lib, File.join($tmpdir, "lib/armeabi")
|
1525
|
+
end
|
1523
1526
|
$ext_android_additional_lib.each do |lib|
|
1524
1527
|
cp_r lib, File.join($tmpdir, "lib/armeabi")
|
1525
1528
|
end
|
@@ -1897,55 +1900,64 @@ namespace "run" do
|
|
1897
1900
|
def run_emulator(options = {})
|
1898
1901
|
apkfile = Jake.get_absolute $targetdir + "/" + $appname + "-debug.apk"
|
1899
1902
|
|
1900
|
-
AndroidTools.kill_adb
|
1903
|
+
#AndroidTools.kill_adb
|
1901
1904
|
Jake.run($adb, ['start-server'], nil, true)
|
1902
|
-
puts 'Sleep for 5 sec. waiting for "adb start-server"'
|
1903
|
-
sleep 5
|
1905
|
+
#puts 'Sleep for 5 sec. waiting for "adb start-server"'
|
1906
|
+
#sleep 5
|
1904
1907
|
|
1905
1908
|
AndroidTools.logcat_process()
|
1906
1909
|
|
1907
|
-
|
1908
|
-
|
1909
|
-
end
|
1910
|
-
|
1911
|
-
createavd = "\"#{$androidbin}\" create avd --name #{$avdname} --target #{$avdtarget} --sdcard 128M "
|
1912
|
-
system("echo no | #{createavd}") unless File.directory?( File.join(ENV['HOME'], ".android", "avd", "#{$avdname}.avd" ) )
|
1910
|
+
running = AndroidTools.is_emulator_running
|
1911
|
+
if !running
|
1913
1912
|
|
1914
|
-
|
1915
|
-
|
1916
|
-
avd_using_gapi = true if File.new(avdini).read =~ /:Google APIs:/
|
1917
|
-
unless avd_using_gapi
|
1918
|
-
puts "Can not use specified AVD (#{$avdname}) because of incompatibility with Google APIs. Delete it and try again."
|
1919
|
-
exit 1
|
1913
|
+
if $appavdname != nil
|
1914
|
+
$avdname = $appavdname
|
1920
1915
|
end
|
1921
|
-
end
|
1922
1916
|
|
1923
|
-
|
1917
|
+
createavd = "\"#{$androidbin}\" create avd --name #{$avdname} --target #{$avdtarget} --sdcard 128M "
|
1918
|
+
system("echo no | #{createavd}") unless File.directory?( File.join(ENV['HOME'], ".android", "avd", "#{$avdname}.avd" ) )
|
1919
|
+
|
1920
|
+
if $use_google_addon_api
|
1921
|
+
avdini = File.join(ENV['HOME'], '.android', 'avd', "#{$avdname}.ini")
|
1922
|
+
avd_using_gapi = true if File.new(avdini).read =~ /:Google APIs:/
|
1923
|
+
unless avd_using_gapi
|
1924
|
+
puts "Can not use specified AVD (#{$avdname}) because of incompatibility with Google APIs. Delete it and try again."
|
1925
|
+
exit 1
|
1926
|
+
end
|
1927
|
+
end
|
1924
1928
|
|
1925
|
-
if !running
|
1926
1929
|
# Start the emulator, check on it every 5 seconds until it's running
|
1927
|
-
cmd = "\"#{$emulator}\" -cpu-delay 0
|
1930
|
+
cmd = "\"#{$emulator}\" -cpu-delay 0"
|
1928
1931
|
cmd << " -no-window" if options[:hidden]
|
1929
1932
|
cmd << " -avd #{$avdname}"
|
1930
1933
|
Thread.new { system(cmd) }
|
1931
1934
|
|
1932
1935
|
puts "Waiting for emulator..."
|
1933
|
-
|
1936
|
+
res = 'error'
|
1937
|
+
while res =~ /error/ do
|
1938
|
+
sleep 5
|
1939
|
+
res = Jake.run $adb, ['-e', 'wait-for-device']
|
1940
|
+
puts res
|
1941
|
+
end
|
1934
1942
|
|
1935
|
-
puts "Waiting up to
|
1943
|
+
puts "Waiting up to 600 seconds for emulator..."
|
1936
1944
|
startedWaiting = Time.now
|
1937
1945
|
adbRestarts = 1
|
1938
|
-
while (Time.now - startedWaiting <
|
1946
|
+
while (Time.now - startedWaiting < 600 )
|
1939
1947
|
sleep 5
|
1940
1948
|
now = Time.now
|
1941
1949
|
started = false
|
1950
|
+
booted = true
|
1942
1951
|
Jake.run2 $adb, ["-e", "shell", "ps"], :system => false, :hideerrors => false do |line|
|
1952
|
+
#puts line
|
1953
|
+
booted = false if line =~ /bootanimation/
|
1943
1954
|
started = true if line =~ /android\.process\.acore/
|
1944
1955
|
true
|
1945
1956
|
end
|
1946
|
-
|
1957
|
+
#puts "started: #{started}, booted: #{booted}"
|
1958
|
+
unless started and booted
|
1947
1959
|
printf("%.2fs: ",(now - startedWaiting))
|
1948
|
-
if (now - startedWaiting) > (
|
1960
|
+
if (now - startedWaiting) > (180 * adbRestarts)
|
1949
1961
|
# Restart the adb server every 60 seconds to prevent eternal waiting
|
1950
1962
|
puts "Appears hung, restarting adb server"
|
1951
1963
|
AndroidTools.kill_adb
|
@@ -30,7 +30,8 @@
|
|
30
30
|
#import <CoreLocation/CoreLocation.h>
|
31
31
|
#import "MapAnnotation.h"
|
32
32
|
|
33
|
-
|
33
|
+
//#define kGeoCodeURL @"http://maps.google.com/maps/geo?q="
|
34
|
+
#define kGeoCodeURL @"http://maps.googleapis.com/maps/api/geocode/json?address="
|
34
35
|
|
35
36
|
@interface GoogleGeocoder : NSObject {
|
36
37
|
NSMutableArray *annotations;
|
@@ -32,6 +32,8 @@
|
|
32
32
|
#undef DEFAULT_LOGCATEGORY
|
33
33
|
#define DEFAULT_LOGCATEGORY "GoogleGeocoder"
|
34
34
|
|
35
|
+
extern void rho_geocoding_parse_json_responce(const char* data, char* adress_buf, int max_adress_length, double* latitude, double* longitude, int* is_adress_ok, int* is_coords_ok);
|
36
|
+
|
35
37
|
@implementation GoogleGeocoder
|
36
38
|
|
37
39
|
@synthesize actionTarget,onDidFindAddress,theElement,annotations,gapikey;
|
@@ -80,16 +82,17 @@
|
|
80
82
|
currentAnnotation = annotation;
|
81
83
|
NSMutableString *url = [[NSMutableString alloc] initWithString:kGeoCodeURL];
|
82
84
|
[url appendString:[annotation address]];
|
83
|
-
[url appendFormat:@"&output=xml"];
|
85
|
+
//[url appendFormat:@"&output=xml"];
|
84
86
|
[url replaceOccurrencesOfString:@"ä" withString:@"ae" options:1 range:(NSRange){0,[url length]}];
|
85
87
|
[url replaceOccurrencesOfString:@"ö" withString:@"oe" options:1 range:(NSRange){0,[url length]}];
|
86
88
|
[url replaceOccurrencesOfString:@"ü" withString:@"ue" options:1 range:(NSRange){0,[url length]}];
|
87
89
|
[url replaceOccurrencesOfString:@"ß" withString:@"ss" options:1 range:(NSRange){0,[url length]}];
|
88
90
|
[url replaceOccurrencesOfString:@" " withString:@"+" options:1 range:(NSRange){0,[url length]}];
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
[url appendString:@"&sensor=false"];
|
92
|
+
//if (gapikey) {
|
93
|
+
// [url appendString:@"&key="];
|
94
|
+
// [url appendString:gapikey];
|
95
|
+
//}
|
93
96
|
NSLog(@"Geocoding url = %@\n", url);
|
94
97
|
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:url]
|
95
98
|
cachePolicy:NSURLRequestUseProtocolCachePolicy
|
@@ -97,10 +100,42 @@
|
|
97
100
|
@try {
|
98
101
|
NSHTTPURLResponse *response = NULL;
|
99
102
|
NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
|
103
|
+
|
104
|
+
|
105
|
+
NSString* data_string = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
106
|
+
|
107
|
+
char adress_buf[2048];
|
108
|
+
int is_adress_ok = 0;
|
109
|
+
int is_coords_ok = 0;
|
110
|
+
double latitude = 0;
|
111
|
+
double longitude = 0;
|
112
|
+
|
113
|
+
rho_geocoding_parse_json_responce([data_string UTF8String], adress_buf, 2048, &latitude, &longitude, &is_adress_ok, &is_coords_ok);
|
114
|
+
|
115
|
+
if (is_adress_ok != 0) {
|
116
|
+
[currentAnnotation setCoordinateString:[NSString stringWithUTF8String:adress_buf]];
|
117
|
+
}
|
118
|
+
|
119
|
+
if (is_coords_ok) {
|
120
|
+
CLLocation *location = [[[CLLocation alloc] initWithLatitude:latitude longitude:longitude] autorelease];
|
121
|
+
[currentAnnotation setCoordinate:location.coordinate];
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
/*
|
126
|
+
const char* curl = [url UTF8String];
|
127
|
+
|
100
128
|
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
|
101
129
|
[parser setDelegate:self];
|
102
130
|
[parser parse];
|
103
|
-
|
131
|
+
*/
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
//[self stringCooridinatesToCLLocation];
|
104
139
|
}
|
105
140
|
@catch (NSException *exception) {
|
106
141
|
NSLog(@"Geocoding failed");
|
@@ -124,6 +159,7 @@
|
|
124
159
|
#pragma mark -
|
125
160
|
#pragma mark XML Parsing Methods
|
126
161
|
|
162
|
+
/*
|
127
163
|
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
|
128
164
|
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
|
129
165
|
attributes:(NSDictionary *)attributeDict {
|
@@ -134,6 +170,7 @@
|
|
134
170
|
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
|
135
171
|
string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
136
172
|
string = [string stringByReplacingOccurrencesOfString:@"\\n" withString:@""];
|
173
|
+
const char* cstring = [string UTF8String];
|
137
174
|
if ([string length] == 0)
|
138
175
|
return;
|
139
176
|
|
@@ -147,6 +184,7 @@
|
|
147
184
|
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
|
148
185
|
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qname {
|
149
186
|
}
|
187
|
+
*/
|
150
188
|
|
151
189
|
|
152
190
|
|
@@ -298,7 +298,16 @@ static MapViewController *mc = nil;
|
|
298
298
|
MapAnnotation *annObj = [[MapAnnotation alloc] init];
|
299
299
|
[annObj setCoordinate:coord];
|
300
300
|
if (address) [annObj setAddress:address];
|
301
|
-
if (title)
|
301
|
+
if (title) {
|
302
|
+
if ([title length] == 0) {
|
303
|
+
if (subtitle) {
|
304
|
+
if ([subtitle length] > 0) {
|
305
|
+
title = @" ";
|
306
|
+
}
|
307
|
+
}
|
308
|
+
}
|
309
|
+
[annObj setTitle:title];
|
310
|
+
}
|
302
311
|
if (subtitle) [annObj setSubtitle:subtitle];
|
303
312
|
if (url) [annObj setUrl:url];
|
304
313
|
if (image) [annObj setImage:image];
|
@@ -0,0 +1,103 @@
|
|
1
|
+
/*------------------------------------------------------------------------
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008-2011 Rhomobile, Inc.
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
14
|
+
* all copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
* THE SOFTWARE.
|
23
|
+
*
|
24
|
+
* http://rhomobile.com
|
25
|
+
*------------------------------------------------------------------------*/
|
26
|
+
|
27
|
+
#include "ExtManager.h"
|
28
|
+
#include "rubyext/WebView.h"
|
29
|
+
|
30
|
+
#if defined (WINDOWS_PLATFORM)
|
31
|
+
extern "C" HWND getMainWnd();
|
32
|
+
extern "C" HINSTANCE rho_wmimpl_get_appinstance();
|
33
|
+
#endif
|
34
|
+
|
35
|
+
namespace rho {
|
36
|
+
namespace common {
|
37
|
+
|
38
|
+
IMPLEMENT_LOGCLASS(CExtManager, "ExtManager");
|
39
|
+
|
40
|
+
void CExtManager::registerExtension(const String& strName, IRhoExtension* pExt)
|
41
|
+
{
|
42
|
+
m_hashExtensions.put(strName, pExt);
|
43
|
+
}
|
44
|
+
|
45
|
+
IRhoExtension* CExtManager::getExtByName(const String& strName)
|
46
|
+
{
|
47
|
+
return m_hashExtensions.get(strName);
|
48
|
+
}
|
49
|
+
|
50
|
+
CRhoExtData CExtManager::makeExtData()
|
51
|
+
{
|
52
|
+
CRhoExtData oData;
|
53
|
+
#if defined (OS_WINDOWS)
|
54
|
+
oData.m_hWnd = getMainWnd();
|
55
|
+
oData.m_hInstance = rho_wmimpl_get_appinstance();
|
56
|
+
#endif
|
57
|
+
|
58
|
+
oData.m_iTabIndex = rho_webview_active_tab();
|
59
|
+
return oData;
|
60
|
+
}
|
61
|
+
|
62
|
+
void CExtManager::onBeforeNavigate()
|
63
|
+
{
|
64
|
+
for ( HashtablePtr<String, IRhoExtension*>::iterator it = m_hashExtensions.begin(); it != m_hashExtensions.end(); ++it )
|
65
|
+
{
|
66
|
+
(it->second)->onBeforeNavigate( makeExtData() );
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
void CExtManager::close()
|
71
|
+
{
|
72
|
+
m_hashExtensions.clear();
|
73
|
+
}
|
74
|
+
|
75
|
+
void CExtManager::onUnhandledProperty( const wchar_t* pModuleName, const wchar_t* pName, const wchar_t* pValue, const CRhoExtData& oExtData )
|
76
|
+
{
|
77
|
+
rho::common::IRhoExtension* pExt = getExtByName( rho::common::convertToStringA(pModuleName) );
|
78
|
+
if (pExt)
|
79
|
+
pExt->onSetProperty( pName, pValue, oExtData );
|
80
|
+
}
|
81
|
+
|
82
|
+
void CExtManager::executeRuby( const char* szMethod, const char* szParam)
|
83
|
+
{
|
84
|
+
}
|
85
|
+
|
86
|
+
void CExtManager::executeRubyCallback( const char* szCallback, const char* szCallbackBody, const char* szCallbackData)
|
87
|
+
{
|
88
|
+
}
|
89
|
+
|
90
|
+
void CExtManager::navigate(const wchar_t* szUrl)
|
91
|
+
{
|
92
|
+
}
|
93
|
+
|
94
|
+
extern "C" unsigned long rb_require(const char *fname);
|
95
|
+
|
96
|
+
void CExtManager::requireRubyFile( const char* szFilePath )
|
97
|
+
{
|
98
|
+
rb_require(szFilePath);
|
99
|
+
}
|
100
|
+
|
101
|
+
} //namespace common
|
102
|
+
} //namespace rho
|
103
|
+
|
@@ -0,0 +1,101 @@
|
|
1
|
+
/*------------------------------------------------------------------------
|
2
|
+
* (The MIT License)
|
3
|
+
*
|
4
|
+
* Copyright (c) 2008-2011 Rhomobile, Inc.
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
14
|
+
* all copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
* THE SOFTWARE.
|
23
|
+
*
|
24
|
+
* http://rhomobile.com
|
25
|
+
*------------------------------------------------------------------------*/
|
26
|
+
|
27
|
+
#ifndef __EXT_MANAGER__H__
|
28
|
+
#define __EXT_MANAGER__H__
|
29
|
+
|
30
|
+
#ifdef __cplusplus
|
31
|
+
|
32
|
+
#include "logging/RhoLog.h"
|
33
|
+
|
34
|
+
#if defined(WINDOWS_PLATFORM)
|
35
|
+
|
36
|
+
namespace rho {
|
37
|
+
namespace common {
|
38
|
+
|
39
|
+
struct CRhoExtData
|
40
|
+
{
|
41
|
+
void* m_hWnd;
|
42
|
+
void* m_hInstance;
|
43
|
+
int m_iTabIndex;
|
44
|
+
};
|
45
|
+
|
46
|
+
struct IRhoExtension
|
47
|
+
{
|
48
|
+
virtual void onSetPropertiesData( const wchar_t* pData, const CRhoExtData& oExtData ){}
|
49
|
+
virtual void onSetProperty( const wchar_t* pName, const wchar_t* pValue, const CRhoExtData& oExtData ){}
|
50
|
+
virtual void onBeforeNavigate(const CRhoExtData& oExtData){}
|
51
|
+
};
|
52
|
+
|
53
|
+
struct IRhoExtManager
|
54
|
+
{
|
55
|
+
virtual void onUnhandledProperty( const wchar_t* pModuleName, const wchar_t* pName, const wchar_t* pValue, const CRhoExtData& oExtData ) = 0;
|
56
|
+
virtual void executeRuby( const char* szMethod, const char* szParam) = 0;
|
57
|
+
virtual void executeRubyCallback( const char* szCallback, const char* szCallbackBody, const char* szCallbackData) = 0;
|
58
|
+
virtual void requireRubyFile( const char* szFilePath ) = 0;
|
59
|
+
|
60
|
+
virtual void navigate(const wchar_t* szUrl) = 0;
|
61
|
+
};
|
62
|
+
|
63
|
+
class CExtManager : public IRhoExtManager
|
64
|
+
{
|
65
|
+
DEFINE_LOGCLASS;
|
66
|
+
|
67
|
+
HashtablePtr<String, IRhoExtension*> m_hashExtensions;
|
68
|
+
|
69
|
+
public:
|
70
|
+
void registerExtension(const String& strName, IRhoExtension* pExt);
|
71
|
+
|
72
|
+
IRhoExtension* getExtByName(const String& strName);
|
73
|
+
void onBeforeNavigate();
|
74
|
+
|
75
|
+
CRhoExtData makeExtData();
|
76
|
+
void close();
|
77
|
+
|
78
|
+
//IRhoExtManager
|
79
|
+
virtual void onUnhandledProperty( const wchar_t* pModuleName, const wchar_t* pName, const wchar_t* pValue, const CRhoExtData& oExtData );
|
80
|
+
virtual void executeRuby( const char* szMethod, const char* szParam);
|
81
|
+
virtual void executeRubyCallback( const char* szCallback, const char* szCallbackBody, const char* szCallbackData);
|
82
|
+
virtual void navigate(const wchar_t* szUrl);
|
83
|
+
virtual void requireRubyFile( const char* szFilePath );
|
84
|
+
|
85
|
+
};
|
86
|
+
|
87
|
+
} //namespace common
|
88
|
+
} //namespace rho
|
89
|
+
|
90
|
+
#else //WINDOWS_PLATFORM
|
91
|
+
class CExtManager
|
92
|
+
{
|
93
|
+
public:
|
94
|
+
void close(){}
|
95
|
+
};
|
96
|
+
|
97
|
+
#endif
|
98
|
+
|
99
|
+
#endif //__cplusplus
|
100
|
+
|
101
|
+
#endif //__EXT_MANAGER__H__
|