rhodes 3.0.0 → 3.0.1.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/CHANGELOG +4 -0
  2. data/Rakefile +9 -2
  3. data/doc/application.txt +1 -1
  4. data/doc/build.txt +49 -70
  5. data/doc/device-caps.txt +22 -97
  6. data/doc/extensions.txt +1 -1
  7. data/doc/nfc.txt +542 -0
  8. data/doc/rhom.txt +7 -5
  9. data/doc/simulator.txt +116 -0
  10. data/doc/ui.txt +1 -1
  11. data/lib/build/jake.rb +5 -5
  12. data/lib/extensions/debugger/debugger.rb +63 -35
  13. data/lib/extensions/nfc/ext/nfc/platform/android/AndroidManifest.xml +8 -6
  14. data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +1070 -249
  15. data/lib/extensions/nfc/ext/nfc/platform/android/res/xml/filter_nfc.xml +1 -5
  16. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +894 -72
  17. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcActivity.java +82 -18
  18. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcMessage.java +65 -0
  19. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcRecord.java +88 -24
  20. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/NfcTechActivity.java +3 -0
  21. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc.i +204 -3
  22. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +1047 -5
  23. data/lib/extensions/nfc/nfc.rb +635 -91
  24. data/lib/extensions/rhoxml/rexml/encodings/CP-1252.rb +103 -0
  25. data/lib/extensions/rhoxml/rexml/encodings/ISO-8859-1.rb +7 -0
  26. data/lib/framework/dateME.rb +26 -0
  27. data/lib/framework/rho/render.rb +21 -9
  28. data/lib/framework/rho/rho.rb +12 -0
  29. data/lib/framework/rho/rhoevent_bb.rb +3 -0
  30. data/lib/framework/rho/rhoevent_c.rb +3 -0
  31. data/lib/framework/rhodes.rb +1 -1
  32. data/lib/framework/rhom/rhom_db_adapter.rb +9 -9
  33. data/lib/framework/rhosystem.rb +17 -0
  34. data/lib/framework/stringio.rb +18 -0
  35. data/lib/framework/version.rb +1 -1
  36. data/lib/rhodes.rb +1 -1
  37. data/platform/android/Rhodes/AndroidManifest.xml +2 -2
  38. data/platform/android/Rhodes/res/xml/filter_nfc.xml +1 -5
  39. data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +0 -2
  40. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +10 -6
  41. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +29 -18
  42. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +67 -12
  43. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivityListener.java +14 -0
  44. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +102 -28
  45. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +35 -66
  46. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +5 -5
  47. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +69 -41
  48. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/PopupActivity.java +7 -5
  49. data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +68 -35
  50. data/platform/android/build/RhodesSRC_build.files +1 -0
  51. data/platform/android/build/android.rake +2 -2
  52. data/platform/bb/RubyVM/src/com/rho/RhoConf.java +1 -0
  53. data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +18 -6
  54. data/platform/bb/build/bb.rake +1 -1
  55. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +5 -4
  56. data/platform/iphone/Classes/SimpleMainView.m +1 -1
  57. data/platform/iphone/Info.plist +1 -1
  58. data/platform/shared/common/RhodesApp.cpp +9 -3
  59. data/platform/shared/curl/lib/rhossl.c +5 -2
  60. data/platform/shared/db/DBAdapter.cpp +9 -0
  61. data/platform/shared/net/CURLNetRequest.cpp +8 -3
  62. data/platform/shared/net/iphone/sslimpl.cpp +3 -2
  63. data/platform/shared/net/ssl.cpp +8 -0
  64. data/platform/shared/ruby/ext/rho/rhoruby.c +10 -0
  65. data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
  66. data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +3 -4
  67. data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
  68. data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
  69. data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
  70. data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
  71. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  72. data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
  73. data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
  74. data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
  75. data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
  76. data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
  77. data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
  78. data/platform/win32/RhoSimulator/libeay32.dll +0 -0
  79. data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
  80. data/platform/wm/build/wm.rake +27 -3
  81. data/platform/wm/rhodes/Rhodes.cpp +4 -0
  82. data/platform/wm/rhodes/emulator/MainWindowCallback.h +1 -0
  83. data/platform/wm/rhodes/emulator/MainWindowProxy.cpp +3 -1
  84. data/platform/wm/rhodes/emulator/MainWindowQt.cpp +23 -12
  85. data/platform/wm/rhodes/emulator/MainWindowQt.h +5 -1
  86. data/platform/wm/rhodes/emulator/QtMainWindow.cpp +39 -6
  87. data/platform/wm/rhodes/emulator/QtMainWindow.h +1 -1
  88. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +5 -0
  89. data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.Libraries.dll +0 -0
  90. data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/IronRuby.dll +0 -0
  91. data/platform/wp7/IronRuby/bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
  92. data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.Core.dll +0 -0
  93. data/platform/wp7/IronRuby/{Bin → bin}/Silverlight3Release/Microsoft.Scripting.dll +0 -0
  94. data/platform/wp7/RhoAppRunner/Program.cs +2 -2
  95. data/platform/wp7/RhoRubyLib/RhoRuby.cs +8 -0
  96. data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +29 -7
  97. data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +5 -2
  98. data/platform/wp7/RhoRubyLib/logging/RhoLogger.cs +12 -0
  99. data/platform/wp7/RhoRubyLib/net/HttpServer.cs +2 -0
  100. data/platform/wp7/RhoRubyLib/net/NetRequest.cs +1 -1
  101. data/platform/wp7/RhoRubyLib/rubyext/RhoAsyncHttp.cs +52 -7
  102. data/platform/wp7/RhoRubyLib/rubyext/RhoDatabase.cs +85 -18
  103. data/platform/wp7/RhoRubyLib/rubyext/RhoJSON.cs +38 -3
  104. data/platform/wp7/RhoRubyLib/rubyext/RhoKernelOps.cs +27 -2
  105. data/platform/wp7/RhoRubyLib/rubyext/RhoNativeBar.cs +111 -15
  106. data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +330 -55
  107. data/platform/wp7/RhoRubyLib/rubyext/RhoWebView.cs +61 -4
  108. data/platform/wp7/build/wp.rake +89 -72
  109. data/platform/wp7/rhodes/App.xaml.cs +1 -1
  110. data/rakefile.rb +9 -2
  111. data/rhodes.gemspec +1 -3
  112. data/spec/phone_spec/app/spec/asynchttp_spec.rb +7 -9
  113. data/spec/phone_spec/app/spec/uri_spec.rb +75 -0
  114. data/spec/phone_spec/app/spec_runner.rb +4 -0
  115. metadata +21 -15
  116. data/Manifest.txt +0 -6403
  117. data/platform/win32/RhoSimulator/codecs/qcncodecs4.dll +0 -0
  118. data/platform/win32/RhoSimulator/codecs/qjpcodecs4.dll +0 -0
  119. data/platform/win32/RhoSimulator/codecs/qkrcodecs4.dll +0 -0
  120. data/platform/win32/RhoSimulator/codecs/qtwcodecs4.dll +0 -0
  121. data/platform/wp7/IronRuby/Bin/Silverlight3Release/Microsoft.Dynamic.dll +0 -0
@@ -4,6 +4,7 @@ using IronRuby.Runtime;
4
4
  using IronRuby.Builtins;
5
5
  using System;
6
6
  using System.Runtime.InteropServices;
7
+ using rho.common;
7
8
 
8
9
  namespace rho.rubyext
9
10
  {
@@ -15,6 +16,9 @@ namespace rho.rubyext
15
16
  {
16
17
  #region Private Implementation Details
17
18
 
19
+ private static RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() :
20
+ new RhoLogger("RhoJSON");
21
+
18
22
  #endregion
19
23
 
20
24
  #region Private Instance & Singleton Methods
@@ -22,15 +26,46 @@ namespace rho.rubyext
22
26
  [RubyMethodAttribute("parse", RubyMethodAttributes.PublicSingleton)]
23
27
  public static object parse(RubyModule/*!*/ self, [NotNull]string/*!*/ strData)
24
28
  {
25
- return fastJSON.RJSONTokener.JsonDecode(strData);
29
+ object res = null;
30
+ try
31
+ {
32
+ res = fastJSON.RJSONTokener.JsonDecode(strData);
33
+ }
34
+ catch (Exception ex)
35
+ {
36
+ Exception rubyEx = self.Context.CurrentException;
37
+ if (rubyEx == null)
38
+ {
39
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
40
+ }
41
+ LOG.ERROR("parse", ex);
42
+ throw rubyEx;
43
+ }
44
+
45
+ return res;
26
46
  }
27
47
 
28
48
  [RubyMethodAttribute("quote_value", RubyMethodAttributes.PublicSingleton)]
29
49
  public static object quote_value(RubyModule/*!*/ self, [NotNull]string/*!*/ strData)
30
50
  {
31
- String strRes = rho.json.JSONEntry.quoteValue(strData);
51
+ object res = null;
52
+ try
53
+ {
54
+ String strRes = rho.json.JSONEntry.quoteValue(strData);
55
+ res = CRhoRuby.Instance.createString(strRes);
56
+ }
57
+ catch (Exception ex)
58
+ {
59
+ Exception rubyEx = self.Context.CurrentException;
60
+ if (rubyEx == null)
61
+ {
62
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
63
+ }
64
+ LOG.ERROR("quote_value", ex);
65
+ throw rubyEx;
66
+ }
32
67
 
33
- return CRhoRuby.Instance.createString(strRes);
68
+ return res;
34
69
  }
35
70
 
36
71
  #endregion
@@ -9,16 +9,41 @@ namespace rho.rubyext
9
9
  {
10
10
  public static class RhoKernelOps
11
11
  {
12
+ private static RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() :
13
+ new RhoLogger("RhoKernelOps");
14
+
15
+ static CRhoRuby RhoRuby { get { return CRhoRuby.Instance; } }
16
+
12
17
  private static CRhodesApp RhodesApp { get { return CRhodesApp.Instance; } }
13
18
 
14
19
  public static Object __rhoGetCallbackObject(Object/*!*/ self, int index)
15
20
  {
16
- return RhodesApp.getCallbackObject(index); ;
21
+ Object res = null;
22
+ try
23
+ {
24
+ res = RhodesApp.getCallbackObject(index);
25
+ }
26
+ catch (Exception ex)
27
+ {
28
+ LOG.HandleRubyException(ex, RhoRuby.rubyContext.CurrentException, "__rhoGetCallbackObject");
29
+ }
30
+
31
+ return res;
17
32
  }
18
33
 
19
34
  public static Object __rho_exist_in_resources(Object/*!*/ self, String path)
20
35
  {
21
- return CRhoFile.isResourceFileExist(path);
36
+ Object res = null;
37
+ try
38
+ {
39
+ res = CRhoFile.isResourceFileExist(path);
40
+ }
41
+ catch (Exception ex)
42
+ {
43
+ LOG.HandleRubyException(ex, RhoRuby.rubyContext.CurrentException, "__rho_exist_in_resources");
44
+ }
45
+
46
+ return res;
22
47
  }
23
48
 
24
49
  }
@@ -14,6 +14,8 @@ namespace rho.rubyext
14
14
 
15
15
  #region Private Implementation Details
16
16
 
17
+ private static RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() :
18
+ new RhoLogger("RhoNativeBar");
17
19
  private static CRhodesApp RhodesApp { get { return CRhodesApp.Instance; } }
18
20
 
19
21
  #endregion
@@ -23,27 +25,66 @@ namespace rho.rubyext
23
25
  [RubyMethodAttribute("create", RubyMethodAttributes.PublicSingleton)]
24
26
  public static void Create(RubyModule/*!*/ self, int barType, RubyArray args)
25
27
  {
26
- if (args != null && args.Count > 0)
27
- RhodesApp.createToolBar(barType, (Object)args);
28
-
29
- if (barType == 2)
30
- RhodesApp.removeToolBar();
28
+ try
29
+ {
30
+ if (args != null && args.Count > 0)
31
+ RhodesApp.createToolBar(barType, (Object)args);
32
+
33
+ if (barType == 2)
34
+ RhodesApp.removeToolBar();
35
+ }
36
+ catch (Exception ex)
37
+ {
38
+ Exception rubyEx = self.Context.CurrentException;
39
+ if (rubyEx == null)
40
+ {
41
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
42
+ }
43
+ LOG.ERROR("create", ex);
44
+ throw rubyEx;
45
+ }
31
46
  }
32
47
 
33
48
  [RubyMethodAttribute("create", RubyMethodAttributes.PublicSingleton)]
34
49
  public static void Create(RubyModule/*!*/ self, int barType, Hash args)
35
50
  {
36
- if (args != null && args.Count > 0)
37
- RhodesApp.createToolBar(barType, (Object)args);
38
-
39
- if (barType == 2)
40
- RhodesApp.removeToolBar();
51
+ try
52
+ {
53
+ if (args != null && args.Count > 0)
54
+ RhodesApp.createToolBar(barType, (Object)args);
55
+
56
+ if (barType == 2)
57
+ RhodesApp.removeToolBar();
58
+ }
59
+ catch (Exception ex)
60
+ {
61
+ Exception rubyEx = self.Context.CurrentException;
62
+ if (rubyEx == null)
63
+ {
64
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
65
+ }
66
+ LOG.ERROR("create", ex);
67
+ throw rubyEx;
68
+ }
41
69
  }
42
70
 
43
71
  [RubyMethodAttribute("remove", RubyMethodAttributes.PublicSingleton)]
44
72
  public static void Remove(RubyModule/*!*/ self)
45
73
  {
46
- RhodesApp.removeToolBar();
74
+ try
75
+ {
76
+ RhodesApp.removeToolBar();
77
+ }
78
+ catch (Exception ex)
79
+ {
80
+ Exception rubyEx = self.Context.CurrentException;
81
+ if (rubyEx == null)
82
+ {
83
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
84
+ }
85
+ LOG.ERROR("remove", ex);
86
+ throw rubyEx;
87
+ }
47
88
  }
48
89
 
49
90
  [RubyMethodAttribute("switch_tab", RubyMethodAttributes.PublicSingleton)]
@@ -55,7 +96,23 @@ namespace rho.rubyext
55
96
  [RubyMethodAttribute("started", RubyMethodAttributes.PublicSingleton)]
56
97
  public static Boolean isStarted(RubyModule/*!*/ self)
57
98
  {
58
- return RhodesApp.barIsStarted;
99
+ Boolean res = false;
100
+ try
101
+ {
102
+ res = RhodesApp.barIsStarted;
103
+ }
104
+ catch (Exception ex)
105
+ {
106
+ Exception rubyEx = self.Context.CurrentException;
107
+ if (rubyEx == null)
108
+ {
109
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
110
+ }
111
+ LOG.ERROR("started", ex);
112
+ throw rubyEx;
113
+ }
114
+
115
+ return res;
59
116
  }
60
117
 
61
118
  [RubyMethodAttribute("set_tab_badge", RubyMethodAttributes.PublicSingleton)]
@@ -67,19 +124,58 @@ namespace rho.rubyext
67
124
  [RubyMethodAttribute("create_native_toolbar", RubyMethodAttributes.PublicSingleton)]
68
125
  public static void createNativeToolBar(RubyModule/*!*/ self, int barType, RubyArray args)
69
126
  {
70
- Create(self, barType, args);
127
+ try
128
+ {
129
+ Create(self, barType, args);
130
+ }
131
+ catch (Exception ex)
132
+ {
133
+ Exception rubyEx = self.Context.CurrentException;
134
+ if (rubyEx == null)
135
+ {
136
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
137
+ }
138
+ LOG.ERROR("create_native_toolbar", ex);
139
+ throw rubyEx;
140
+ }
71
141
  }
72
142
 
73
143
  [RubyMethodAttribute("create_native_toolbar", RubyMethodAttributes.PublicSingleton)]
74
144
  public static void createNativeToolBar(RubyModule/*!*/ self, int barType, Hash args)
75
145
  {
76
- Create(self, barType, args);
146
+ try
147
+ {
148
+ Create(self, barType, args);
149
+ }
150
+ catch (Exception ex)
151
+ {
152
+ Exception rubyEx = self.Context.CurrentException;
153
+ if (rubyEx == null)
154
+ {
155
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
156
+ }
157
+ LOG.ERROR("create_native_toolbar", ex);
158
+ throw rubyEx;
159
+ }
77
160
  }
78
161
 
79
162
  [RubyMethodAttribute("remove_native_toolbar", RubyMethodAttributes.PublicSingleton)]
80
163
  public static void removeNativeToolBar(RubyModule/*!*/ self)
81
164
  {
82
- Remove(self);
165
+ try
166
+ {
167
+ Remove(self);
168
+ }
169
+ catch (Exception ex)
170
+ {
171
+ Exception rubyEx = self.Context.CurrentException;
172
+ if (rubyEx == null)
173
+ {
174
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
175
+ }
176
+ LOG.ERROR("remove_native_toolbar", ex);
177
+ throw rubyEx;
178
+ }
83
179
  }
84
180
 
85
181
  [RubyMethodAttribute("create_native_tabbar", RubyMethodAttributes.PublicSingleton)]
@@ -19,69 +19,169 @@ namespace rho.rubyext
19
19
  [RubyMethod("dosync", RubyMethodAttributes.PublicSingleton)]
20
20
  public static object dosync(RubyModule/*!*/ self)
21
21
  {
22
- SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncAll, false));
23
- return SyncThread.getInstance().getRetValue();
22
+ object res = null;
23
+ try
24
+ {
25
+ SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncAll, false));
26
+
27
+ res = SyncThread.getInstance().getRetValue();
28
+ }
29
+ catch (Exception ex)
30
+ {
31
+ Exception rubyEx = self.Context.CurrentException;
32
+ if (rubyEx == null)
33
+ {
34
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
35
+ }
36
+ LOG.ERROR("dosync", ex);
37
+ throw rubyEx;
38
+ }
39
+
40
+ return res;
24
41
  }
25
42
 
26
43
  [RubyMethod("dosync", RubyMethodAttributes.PublicSingleton)]
27
44
  public static object dosync(RubyModule/*!*/ self, bool/*!*/ show_status_popup)
28
45
  {
29
- SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncAll, show_status_popup));
30
- return SyncThread.getInstance().getRetValue();
46
+ object res = null;
47
+ try
48
+ {
49
+ SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncAll, show_status_popup));
50
+
51
+ res = SyncThread.getInstance().getRetValue();
52
+ }
53
+ catch (Exception ex)
54
+ {
55
+ Exception rubyEx = self.Context.CurrentException;
56
+ if (rubyEx == null)
57
+ {
58
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
59
+ }
60
+ LOG.ERROR("dosync", ex);
61
+ throw rubyEx;
62
+ }
63
+
64
+ return res;
31
65
  }
32
66
 
33
67
  [RubyMethod("dosync_source", RubyMethodAttributes.PublicSingleton)]
34
68
  public static object dosync_source(RubyModule/*!*/ self, [NotNull]object/*!*/ srcID)
35
69
  {
36
- int nSrcID = 0;
37
- String strName = "";
38
- if (srcID is long)
39
- nSrcID = (int)(long)srcID;
40
- else if (srcID is int)
41
- nSrcID = (int)srcID;
42
- else
43
- strName = srcID.ToString();
70
+ object res = null;
71
+ try
72
+ {
73
+ int nSrcID = 0;
74
+ String strName = "";
75
+ if (srcID is long)
76
+ nSrcID = (int)(long)srcID;
77
+ else if (srcID is int)
78
+ nSrcID = (int)srcID;
79
+ else
80
+ strName = srcID.ToString();
81
+
82
+ SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncOne, strName, nSrcID, true));
83
+
84
+ res = SyncThread.getInstance().getRetValue();
85
+ }
86
+ catch (Exception ex)
87
+ {
88
+ Exception rubyEx = self.Context.CurrentException;
89
+ if (rubyEx == null)
90
+ {
91
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
92
+ }
93
+ LOG.ERROR("dosync_source", ex);
94
+ throw rubyEx;
95
+ }
44
96
 
45
- SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncOne, strName, nSrcID, true));
46
- return SyncThread.getInstance().getRetValue();
97
+ return res;
47
98
  }
48
99
 
49
100
  [RubyMethod("dosync_source", RubyMethodAttributes.PublicSingleton)]
50
101
  public static object dosync_source(RubyModule/*!*/ self, [NotNull]object/*!*/ srcID, bool/*!*/ show_status_popup)
51
102
  {
52
- int nSrcID = 0;
53
- String strName = "";
54
- if (srcID is long)
55
- nSrcID = (int)(long)srcID;
56
- else if (srcID is int)
57
- nSrcID = (int)srcID;
58
- else
59
- strName = srcID.ToString();
103
+ object res = null;
104
+ try
105
+ {
106
+ int nSrcID = 0;
107
+ String strName = "";
108
+ if (srcID is long)
109
+ nSrcID = (int)(long)srcID;
110
+ else if (srcID is int)
111
+ nSrcID = (int)srcID;
112
+ else
113
+ strName = srcID.ToString();
114
+
115
+ SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncOne, strName, nSrcID, show_status_popup));
116
+
117
+ res = SyncThread.getInstance().getRetValue();
118
+ }
119
+ catch (Exception ex)
120
+ {
121
+ Exception rubyEx = self.Context.CurrentException;
122
+ if (rubyEx == null)
123
+ {
124
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
125
+ }
126
+ LOG.ERROR("dosync_source", ex);
127
+ throw rubyEx;
128
+ }
60
129
 
61
- SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncOne, strName, nSrcID, show_status_popup));
62
- return SyncThread.getInstance().getRetValue();
130
+ return res;
63
131
  }
64
132
 
65
133
  [RubyMethod("dosearch", RubyMethodAttributes.PublicSingleton)]
66
134
  public static object dosearch(RubyModule/*!*/ self, [NotNull]RubyArray/*!*/ arSourcesR, [NotNull]String/*!*/ from, [NotNull]String/*!*/ strParams,
67
135
  [NotNull]bool/*!*/ bSearchSyncChanges, [NotNull]int/*!*/ nProgressStep, String/*!*/ strCallback, String/*!*/ strCallbackParams)
68
136
  {
69
- SyncThread.stopSync();
137
+ object res = null;
138
+ try
139
+ {
140
+ SyncThread.stopSync();
70
141
 
71
- if ( strCallback != null && strCallback.Length > 0 )
72
- SyncThread.getSyncEngine().getNotify().setSearchNotification(strCallback, strCallbackParams);
142
+ if (strCallback != null && strCallback.Length > 0)
143
+ SyncThread.getSyncEngine().getNotify().setSearchNotification(strCallback, strCallbackParams);
73
144
 
74
- Vector<String> arSources = RhoRuby.makeVectorStringFromArray(arSourcesR);
145
+ Vector<String> arSources = RhoRuby.makeVectorStringFromArray(arSourcesR);
75
146
 
76
- SyncThread.getInstance().addQueueCommand(new SyncThread.SyncSearchCommand(from, strParams, arSources, bSearchSyncChanges, nProgressStep));
147
+ SyncThread.getInstance().addQueueCommand(new SyncThread.SyncSearchCommand(from, strParams, arSources, bSearchSyncChanges, nProgressStep));
148
+
149
+ res = SyncThread.getInstance().getRetValue();
150
+ }
151
+ catch (Exception ex)
152
+ {
153
+ Exception rubyEx = self.Context.CurrentException;
154
+ if (rubyEx == null)
155
+ {
156
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
157
+ }
158
+ LOG.ERROR("dosearch", ex);
159
+ throw rubyEx;
160
+ }
77
161
 
78
- return SyncThread.getInstance().getRetValue();
162
+ return res;
79
163
  }
80
164
 
81
165
  [RubyMethod("logged_in", RubyMethodAttributes.PublicSingleton)]
82
166
  public static int logged_in(RubyModule/*!*/ self)
83
167
  {
84
- return SyncThread.getSyncEngine().isLoggedIn() ? 1 : 0;
168
+ int res = 0;
169
+ try
170
+ {
171
+ res = SyncThread.getSyncEngine().isLoggedIn() ? 1 : 0;
172
+ }
173
+ catch (Exception ex)
174
+ {
175
+ Exception rubyEx = self.Context.CurrentException;
176
+ if (rubyEx == null)
177
+ {
178
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
179
+ }
180
+ LOG.ERROR("logged_in", ex);
181
+ throw rubyEx;
182
+ }
183
+
184
+ return res;
85
185
  }
86
186
 
87
187
  [RubyMethod("login", RubyMethodAttributes.PublicSingleton)]
@@ -106,94 +206,269 @@ namespace rho.rubyext
106
206
  [RubyMethod("set_notification", RubyMethodAttributes.PublicSingleton)]
107
207
  public static void set_notification(RubyModule/*!*/ self, [NotNull]int/*!*/ nSrcID, [NotNull]String/*!*/ url, string/*!*/ callback_param)
108
208
  {
109
- SyncThread.getSyncEngine().getNotify().setSyncNotification(nSrcID,
110
- new SyncNotify.SyncNotification(url, callback_param != null ? callback_param : "", nSrcID != -1));
209
+ try
210
+ {
211
+ SyncThread.getSyncEngine().getNotify().setSyncNotification(nSrcID,
212
+ new SyncNotify.SyncNotification(url, callback_param != null ? callback_param : "", nSrcID != -1));
213
+ }
214
+ catch (Exception ex)
215
+ {
216
+ Exception rubyEx = self.Context.CurrentException;
217
+ if (rubyEx == null)
218
+ {
219
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
220
+ }
221
+ LOG.ERROR("set_notification", ex);
222
+ throw rubyEx;
223
+ }
111
224
  }
112
225
 
113
226
  [RubyMethod("enable_status_popup", RubyMethodAttributes.PublicSingleton)]
114
227
  public static void enable_status_popup(RubyModule/*!*/ self, bool/*!*/ bEnable)
115
228
  {
116
- SyncThread.getSyncEngine().getNotify().enableStatusPopup(bEnable);
229
+ try
230
+ {
231
+ SyncThread.getSyncEngine().getNotify().enableStatusPopup(bEnable);
232
+ }
233
+ catch (Exception ex)
234
+ {
235
+ Exception rubyEx = self.Context.CurrentException;
236
+ if (rubyEx == null)
237
+ {
238
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
239
+ }
240
+ LOG.ERROR("enable_status_popup", ex);
241
+ throw rubyEx;
242
+ }
117
243
  }
118
244
 
119
245
  [RubyMethod("is_blob_attr", RubyMethodAttributes.PublicSingleton)]
120
246
  public static bool is_blob_attr(RubyModule/*!*/ self, [NotNull]String/*!*/ strPartition, [NotNull]int/*!*/ nSrcID, [NotNull]String/*!*/ strAttrName)
121
247
  {
122
- return DBAdapter.getDB(strPartition).getAttrMgr().isBlobAttr(nSrcID, strAttrName);
248
+ bool res = false;
249
+ try
250
+ {
251
+ res = DBAdapter.getDB(strPartition).getAttrMgr().isBlobAttr(nSrcID, strAttrName);
252
+ }
253
+ catch (Exception ex)
254
+ {
255
+ Exception rubyEx = self.Context.CurrentException;
256
+ if (rubyEx == null)
257
+ {
258
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
259
+ }
260
+ LOG.ERROR("is_blob_attr", ex);
261
+ throw rubyEx;
262
+ }
263
+
264
+ return res;
123
265
  }
124
266
 
125
267
  [RubyMethod("update_blob_attribs", RubyMethodAttributes.PublicSingleton)]
126
268
  public static void update_blob_attribs(RubyModule/*!*/ self, [NotNull]String/*!*/ strPartition, [NotNull]int/*!*/ srcID)
127
269
  {
128
- DBAdapter db = DBAdapter.getDB(strPartition);
129
- db.getAttrMgr().loadBlobAttrs(db);
270
+ try
271
+ {
272
+ DBAdapter db = DBAdapter.getDB(strPartition);
273
+ db.getAttrMgr().loadBlobAttrs(db);
274
+ }
275
+ catch (Exception ex)
276
+ {
277
+ Exception rubyEx = self.Context.CurrentException;
278
+ if (rubyEx == null)
279
+ {
280
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
281
+ }
282
+ LOG.ERROR("update_blob_attribs", ex);
283
+ throw rubyEx;
284
+ }
130
285
  }
131
286
 
132
287
  [RubyMethod("set_threaded_mode", RubyMethodAttributes.PublicSingleton)]
133
288
  public static void set_threaded_mode(RubyModule/*!*/ self, [NotNull]bool/*!*/ bThreadMode)
134
289
  {
135
- SyncThread.getInstance().setNonThreadedMode(!bThreadMode);
136
- SyncThread.getSyncEngine().setNonThreadedMode(!bThreadMode);
290
+ try
291
+ {
292
+ SyncThread.getInstance().setNonThreadedMode(!bThreadMode);
293
+ SyncThread.getSyncEngine().setNonThreadedMode(!bThreadMode);
294
+ }
295
+ catch (Exception ex)
296
+ {
297
+ Exception rubyEx = self.Context.CurrentException;
298
+ if (rubyEx == null)
299
+ {
300
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
301
+ }
302
+ LOG.ERROR("set_threaded_mode", ex);
303
+ throw rubyEx;
304
+ }
137
305
  }
138
306
 
139
307
  [RubyMethod("logout", RubyMethodAttributes.PublicSingleton)]
140
308
  public static void logout(RubyModule/*!*/ self)
141
309
  {
142
- SyncThread.stopSync();
143
- SyncThread.getSyncEngine().stopSyncByUser();
144
- SyncThread.getSyncEngine().logout();
310
+ try
311
+ {
312
+ SyncThread.stopSync();
313
+ SyncThread.getSyncEngine().stopSyncByUser();
314
+ SyncThread.getSyncEngine().logout();
315
+ }
316
+ catch (Exception ex)
317
+ {
318
+ Exception rubyEx = self.Context.CurrentException;
319
+ if (rubyEx == null)
320
+ {
321
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
322
+ }
323
+ LOG.ERROR("logout", ex);
324
+ throw rubyEx;
325
+ }
145
326
  }
146
327
 
147
328
  [RubyMethod("set_syncserver", RubyMethodAttributes.PublicSingleton)]
148
329
  public static void set_syncserver(RubyModule/*!*/ self, [NotNull]String/*!*/ syncserver)
149
330
  {
150
- SyncThread.stopSync();
151
- SyncThread.getSyncEngine().setSyncServer(syncserver);
152
331
 
153
- if (syncserver != null && syncserver.length() > 0)
332
+ try
154
333
  {
155
- SyncThread.getInstance().start(SyncThread.epLow);
156
- if (ClientRegister.getInstance() != null)
157
- ClientRegister.getInstance().startUp();
334
+ SyncThread.stopSync();
335
+ SyncThread.getSyncEngine().setSyncServer(syncserver);
336
+
337
+ if (syncserver != null && syncserver.length() > 0)
338
+ {
339
+ SyncThread.getInstance().start(SyncThread.epLow);
340
+ if (ClientRegister.getInstance() != null)
341
+ ClientRegister.getInstance().startUp();
342
+ }
343
+ }
344
+ catch (Exception ex)
345
+ {
346
+ Exception rubyEx = self.Context.CurrentException;
347
+ if (rubyEx == null)
348
+ {
349
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
350
+ }
351
+ LOG.ERROR("set_syncserver", ex);
352
+ throw rubyEx;
158
353
  }
159
354
  }
160
355
 
161
356
  [RubyMethod("set_pollinterval", RubyMethodAttributes.PublicSingleton)]
162
357
  public static int set_pollinterval(RubyModule/*!*/ self, [NotNull]int/*!*/ nInterval)
163
358
  {
164
- int nOldInterval = SyncThread.getInstance().getPollInterval();
165
- SyncThread.getInstance().setPollInterval(nInterval);
359
+ int nOldInterval = 0;
360
+ try
361
+ {
362
+ nOldInterval = SyncThread.getInstance().getPollInterval();
363
+ SyncThread.getInstance().setPollInterval(nInterval);
364
+ }
365
+ catch (Exception ex)
366
+ {
367
+ Exception rubyEx = self.Context.CurrentException;
368
+ if (rubyEx == null)
369
+ {
370
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
371
+ }
372
+ LOG.ERROR("set_pollinterval", ex);
373
+ throw rubyEx;
374
+ }
375
+
166
376
  return nOldInterval;
167
377
  }
168
378
 
169
379
  [RubyMethod("stop_sync", RubyMethodAttributes.PublicSingleton)]
170
380
  public static void set_pollinterval(RubyModule/*!*/ self)
171
381
  {
172
- SyncThread.stopSync();
382
+ try
383
+ {
384
+ SyncThread.stopSync();
385
+ }
386
+ catch (Exception ex)
387
+ {
388
+ Exception rubyEx = self.Context.CurrentException;
389
+ if (rubyEx == null)
390
+ {
391
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
392
+ }
393
+ LOG.ERROR("stop_sync", ex);
394
+ throw rubyEx;
395
+ }
173
396
  }
174
397
 
175
398
  [RubyMethod("set_source_property", RubyMethodAttributes.PublicSingleton)]
176
399
  public static void set_source_property(RubyModule/*!*/ self, [NotNull]int/*!*/ nSrcID, [NotNull]String/*!*/ strPropName, [NotNull]String/*!*/ strPropValue)
177
400
  {
178
- SyncEngine.getSourceOptions().setProperty(nSrcID, strPropName, strPropValue);
401
+ try
402
+ {
403
+ SyncEngine.getSourceOptions().setProperty(nSrcID, strPropName, strPropValue);
404
+ }
405
+ catch (Exception ex)
406
+ {
407
+ Exception rubyEx = self.Context.CurrentException;
408
+ if (rubyEx == null)
409
+ {
410
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
411
+ }
412
+ LOG.ERROR("set_source_property", ex);
413
+ throw rubyEx;
414
+ }
179
415
  }
180
416
 
181
417
  [RubyMethod("set_objectnotify_url", RubyMethodAttributes.PublicSingleton)]
182
418
  public static void set_objectnotify_url(RubyModule/*!*/ self, [DefaultProtocol, NotNull]string/*!*/ url)
183
419
  {
184
- SyncNotify.setObjectNotifyUrl(url);
420
+ try
421
+ {
422
+ SyncNotify.setObjectNotifyUrl(url);
423
+ }
424
+ catch (Exception ex)
425
+ {
426
+ Exception rubyEx = self.Context.CurrentException;
427
+ if (rubyEx == null)
428
+ {
429
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
430
+ }
431
+ LOG.ERROR("set_objectnotify_url", ex);
432
+ throw rubyEx;
433
+ }
185
434
  }
186
435
 
187
436
  [RubyMethod("add_objectnotify", RubyMethodAttributes.PublicSingleton)]
188
437
  public static void add_objectnotify(RubyModule/*!*/ self, [NotNull]int/*!*/ nSrcID, [NotNull]string/*!*/ strObject)
189
438
  {
190
- SyncThread.getSyncEngine().getNotify().addObjectNotify(nSrcID, strObject);
439
+ try
440
+ {
441
+ SyncThread.getSyncEngine().getNotify().addObjectNotify(nSrcID, strObject);
442
+ }
443
+ catch (Exception ex)
444
+ {
445
+ Exception rubyEx = self.Context.CurrentException;
446
+ if (rubyEx == null)
447
+ {
448
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
449
+ }
450
+ LOG.ERROR("add_objectnotify", ex);
451
+ throw rubyEx;
452
+ }
191
453
  }
192
454
 
193
455
  [RubyMethod("clean_objectnotify", RubyMethodAttributes.PublicSingleton)]
194
456
  public static void clean_objectnotify(RubyModule/*!*/ self)
195
457
  {
196
- SyncThread.getSyncEngine().getNotify().cleanObjectNotifications();
458
+ try
459
+ {
460
+ SyncThread.getSyncEngine().getNotify().cleanObjectNotifications();
461
+ }
462
+ catch (Exception ex)
463
+ {
464
+ Exception rubyEx = self.Context.CurrentException;
465
+ if (rubyEx == null)
466
+ {
467
+ rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
468
+ }
469
+ LOG.ERROR("clean_objectnotify", ex);
470
+ throw rubyEx;
471
+ }
197
472
  }
198
473
  }
199
474
  }