rhodes 3.3.1 → 3.3.2.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. data/CHANGELOG +9 -2
  2. data/Manifest.txt +20 -0
  3. data/Rakefile +2 -1
  4. data/doc/build.txt +9 -3
  5. data/doc/configuration.txt +5 -1
  6. data/doc/device-caps.txt +112 -27
  7. data/doc/extensions.txt +0 -51
  8. data/doc/generator.txt +6 -0
  9. data/doc/rhom.txt +3 -0
  10. data/doc/simulator.txt +57 -17
  11. data/doc/ui.txt +24 -27
  12. data/installer/RHOELEMENTS-EULA.txt +295 -0
  13. data/installer/Rakefile +75 -49
  14. data/installer/rhostudio-moto.nsi +534 -0
  15. data/installer/rhostudio.nsi +13 -4
  16. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/barcode.m +3 -0
  17. data/lib/framework/rho/rhoapplication.rb +4 -0
  18. data/lib/framework/rho/rhoevent.rb +2 -3
  19. data/lib/framework/rho/rhoevent_c.rb +2 -2
  20. data/lib/framework/rho/rhofsconnector.rb +24 -2
  21. data/lib/framework/rhodes.rb +1 -1
  22. data/lib/framework/version.rb +1 -1
  23. data/lib/rhodes.rb +1 -1
  24. data/platform/android/Rhodes/AndroidManifest.xml +3 -3
  25. data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +164 -90
  26. data/platform/android/Rhodes/jni/src/signature.cpp +13 -3
  27. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoCryptImpl.java +76 -34
  28. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +3 -4
  29. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +1 -1
  30. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +10 -2
  31. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/AnnotationsOverlay.java +0 -3
  32. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Callout.java +6 -5
  33. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/GoogleMapView.java +0 -1
  34. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/ImageCapture.java +7 -1
  35. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/Signature.java +46 -6
  36. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/SignatureView.java +29 -1
  37. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientOld.java +2 -0
  38. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +4 -0
  39. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsOld.java +10 -2
  40. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebViewClient.java +3 -2
  41. data/platform/android/build/android.rake +6 -27
  42. data/platform/android/build/androidcommon.rb +1 -1
  43. data/platform/bb/rhodes/src/com/rho/rubyext/GeoLocation.java +26 -0
  44. data/platform/iphone/Classes/AppManager/AppManager.h +1 -0
  45. data/platform/iphone/Classes/AppManager/AppManager.m +70 -12
  46. data/platform/iphone/Classes/Camera/PickImageDelegate.m +1 -1
  47. data/platform/iphone/Classes/Event/Event.m +38 -3
  48. data/platform/iphone/Classes/Rhodes.m +3 -2
  49. data/platform/iphone/Classes/Signature/SignatureDelegate.m +1 -1
  50. data/platform/iphone/Info.plist +1 -1
  51. data/platform/iphone/rbuild/iphone.rake +8 -8
  52. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore +0 -0
  53. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui +0 -0
  54. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork +0 -0
  55. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtWebKit.framework/Versions/4/QtWebKit +0 -0
  56. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/phonon.framework/Versions/4/phonon +0 -0
  57. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Info.plist +1 -1
  58. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/MacOS/RhoSimulator +0 -0
  59. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/accessible/libqtaccessiblewidgets.dylib +0 -0
  60. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/bearer/libqcorewlanbearer.dylib +0 -0
  61. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/bearer/libqgenericbearer.dylib +0 -0
  62. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqcncodecs.dylib +0 -0
  63. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqjpcodecs.dylib +0 -0
  64. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqkrcodecs.dylib +0 -0
  65. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqtwcodecs.dylib +0 -0
  66. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/graphicssystems/libqtracegraphicssystem.dylib +0 -0
  67. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqgif.dylib +0 -0
  68. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqico.dylib +0 -0
  69. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqjpeg.dylib +0 -0
  70. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqmng.dylib +0 -0
  71. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqtiff.dylib +0 -0
  72. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/phonon_backend/libphonon_qt7.dylib +0 -0
  73. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/qmltooling/libqmldbg_tcp.dylib +0 -0
  74. data/platform/osx/bin/RhoSimulator/RhoSimulatorMac.zip +0 -0
  75. data/platform/osx/build/osx.rake +1 -1
  76. data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +1 -1
  77. data/platform/shared/common/RhoConf.cpp +15 -6
  78. data/platform/shared/common/RhoConf.h +6 -1
  79. data/platform/shared/common/RhodesApp.cpp +19 -6
  80. data/platform/shared/common/RhodesApp.h +4 -2
  81. data/platform/shared/common/RhodesAppBase.cpp +18 -10
  82. data/platform/shared/common/RhodesAppBase.h +6 -3
  83. data/platform/shared/common/map/GeocodingMapEngine.h +2 -2
  84. data/platform/shared/logging/RhoLogConf.cpp +14 -8
  85. data/platform/shared/logging/RhoLogConf.h +1 -0
  86. data/platform/shared/net/HttpServer.cpp +15 -3
  87. data/platform/shared/net/HttpServer.h +2 -1
  88. data/platform/shared/qt/curl/curl.pro +1 -1
  89. data/platform/shared/qt/rhodes/QtMainWindow.h +1 -1
  90. data/platform/shared/qt/rhodes/impl/MainWindowImpl.cpp +2 -2
  91. data/platform/shared/qt/rhodes/main.cpp +2 -1
  92. data/platform/shared/ruby/ext/rho/rhoruby.c +1 -0
  93. data/platform/shared/ruby/ext/rho/rhosupport.c +11 -1
  94. data/platform/shared/sync/SyncNotify.cpp +1 -2
  95. data/platform/shared/sync/SyncNotify.h +2 -2
  96. data/platform/shared/sync/SyncThread.cpp +27 -12
  97. data/platform/shared/sync/SyncThread.h +2 -0
  98. data/platform/shared/unzip/unzip.cpp +3 -2
  99. data/platform/win32/RhoSimulator/Microsoft.VC80.CRT.manifest +8 -0
  100. data/platform/win32/RhoSimulator/Microsoft.VC80.OpenMP.manifest +7 -0
  101. data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
  102. data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
  103. data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
  104. data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
  105. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  106. data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
  107. data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
  108. data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
  109. data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
  110. data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
  111. data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
  112. data/platform/win32/RhoSimulator/libeay32.dll +0 -0
  113. data/platform/win32/RhoSimulator/msvcm80.dll +0 -0
  114. data/platform/win32/RhoSimulator/msvcp80.dll +0 -0
  115. data/platform/win32/RhoSimulator/msvcr80.dll +0 -0
  116. data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
  117. data/platform/win32/RhoSimulator/vcomp.dll +0 -0
  118. data/platform/wm/build/rhodes.nsi +316 -0
  119. data/platform/wm/build/wm.rake +57 -10
  120. data/platform/wm/rhodes/Rhodes.cpp +2 -1
  121. data/platform/wm/rhodes/rhodes.vcproj +2 -0
  122. data/platform/wm/tools/wmdc_connect.sln +20 -0
  123. data/platform/wm/tools/wmdc_connect/stdafx.cpp +27 -0
  124. data/platform/wm/tools/wmdc_connect/stdafx.h +35 -0
  125. data/platform/wm/tools/wmdc_connect/wmdc_connect.cpp +119 -0
  126. data/platform/wm/tools/wmdc_connect/wmdc_connect.vcproj +205 -0
  127. data/platform/wp7/RhoRubyExtGen/RhoAlert.cs +73 -0
  128. data/platform/wp7/RhoRubyExtGen/RhoRubyExtGen.csproj +1 -0
  129. data/platform/wp7/RhoRubyExtGen/RhoSyncEngine.cs +8 -8
  130. data/platform/wp7/RhoRubyLib/Initializers.Generated.cs +47 -6
  131. data/platform/wp7/RhoRubyLib/RhoRuby.cs +8 -0
  132. data/platform/wp7/RhoRubyLib/RhoRubyLib.csproj +5 -0
  133. data/platform/wp7/RhoRubyLib/WP_PlatformAdaptationLayer.cs +5 -0
  134. data/platform/wp7/RhoRubyLib/common/RhoParams.cs +2 -1
  135. data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +58 -37
  136. data/platform/wp7/RhoRubyLib/db/DBAdapter.cs +37 -0
  137. data/platform/wp7/RhoRubyLib/db/DBAttrManager.cs +63 -1
  138. data/platform/wp7/RhoRubyLib/db/IDBStorage.cs +2 -0
  139. data/platform/wp7/RhoRubyLib/db/SqliteStorage.cs +27 -0
  140. data/platform/wp7/RhoRubyLib/logging/RhoLogServerSink.cs +2 -2
  141. data/platform/wp7/RhoRubyLib/net/NetRequest.cs +4 -3
  142. data/platform/wp7/RhoRubyLib/rubyext/RhoAlert.cs +160 -0
  143. data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +44 -12
  144. data/platform/wp7/RhoRubyLib/sync/ClientRegister.cs +4 -3
  145. data/platform/wp7/RhoRubyLib/sync/SyncEngine.cs +27 -32
  146. data/platform/wp7/RhoRubyLib/sync/SyncNotify.cs +31 -11
  147. data/platform/wp7/RhoRubyLib/sync/SyncProtocol_3.cs +6 -1
  148. data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +4 -0
  149. data/platform/wp7/RhoRubyLib/sync/SyncThread.cs +21 -15
  150. data/platform/wp7/build/wp.rake +6 -0
  151. data/rakefile.rb +2 -1
  152. data/res/build-tools/Coding4Fun.Phone.Controls.dll +0 -0
  153. data/res/build-tools/wmdc_connect.exe +0 -0
  154. data/res/generators/templates/spec/app/SpecRunner/index.erb +14 -13
  155. data/spec/phone_spec/app/spec/rhom_object_spec.rb +10 -1
  156. data/version +1 -1
  157. metadata +26 -4
@@ -107,10 +107,47 @@ namespace rho.db
107
107
  }
108
108
  }
109
109
 
110
+ public static void SyncBlob_DeleteSchemaCallback(Sqlite3.sqlite3_context dbContext, int nArgs, Sqlite3.Mem[] Args)
111
+ {
112
+ String value = Sqlite3.sqlite3_value_text(Args[0]);
113
+ if (value == null) return;
114
+ String strFilePath = RHODESAPP().resolveDBFilesPath(value);
115
+ if (strFilePath != "")
116
+ CRhoFile.deleteFile(strFilePath);
117
+ }
118
+
119
+ public static void SyncBlob_UpdateSchemaCallback(Sqlite3.sqlite3_context dbContext, int nArgs, Sqlite3.Mem[] Args)
120
+ {
121
+ String szOldValue = Sqlite3.sqlite3_value_text(Args[0]);
122
+ String szNewValue = Sqlite3.sqlite3_value_text(Args[1]);
123
+
124
+ if ( szOldValue == szNewValue || szOldValue == null )
125
+ return;
126
+
127
+ if ( szOldValue != null && szNewValue != null && szOldValue == szNewValue )
128
+ return;
129
+
130
+ if (szOldValue != null)
131
+ {
132
+ String strFilePath = RHODESAPP().resolveDBFilesPath(szOldValue);
133
+ CRhoFile.deleteFile(strFilePath);
134
+ }
135
+ }
136
+
110
137
  private void setDbPartition(String strPartition)
111
138
  {
112
139
  m_strDbPartition = strPartition;
113
140
  }
141
+
142
+ public void createTrigger(String strSQL)
143
+ {
144
+ m_dbStorage.createTrigger(strSQL);
145
+ }
146
+
147
+ public void dropTrigger(String strName)
148
+ {
149
+ m_dbStorage.dropTrigger(strName);
150
+ }
114
151
 
115
152
  public void close()
116
153
  {
@@ -26,6 +26,7 @@
26
26
 
27
27
  using System;
28
28
  using rho.common;
29
+ using System.Collections.Generic;
29
30
 
30
31
  namespace rho.db
31
32
  {
@@ -73,7 +74,68 @@ namespace rho.db
73
74
  public void loadBlobAttrs(DBAdapter db)
74
75
  {
75
76
  loadAttrs(db, m_mapBlobAttrs, "blob_attribs", m_mapSrcNames);
76
- //TODO: update/delete trigger for schema sources
77
+
78
+ String strTriggerPrefix = "rhoSchemaTrigger_";
79
+ IDBResult res = db.executeSQL("SELECT name FROM sqlite_master WHERE type='trigger'");
80
+ Hashtable<String, int> mapTriggers = new Hashtable<String, int>();
81
+ for (; !res.isEnd(); res.next())
82
+ {
83
+ String strName = res.getStringByIdx(0);
84
+ if (!strName.startsWith(strTriggerPrefix))
85
+ continue;
86
+
87
+ mapTriggers[strName.Substring(strTriggerPrefix.length())] = 0;
88
+ }
89
+
90
+ foreach (KeyValuePair<int, Hashtable<String,int>> kvpBlobAttrs in m_mapBlobAttrs)
91
+ {
92
+ int nSrcID = kvpBlobAttrs.Key;
93
+
94
+ res = db.executeSQL("SELECT name FROM sources WHERE source_id=?", nSrcID);
95
+ if ( res.isEnd() )
96
+ continue;
97
+
98
+ String strName = res.getStringByIdx(0);
99
+ if ( !db.isTableExist(strName) )
100
+ continue;
101
+
102
+ Hashtable<String,int> hashAttribs = kvpBlobAttrs.Value;
103
+ foreach (KeyValuePair<String, int> kvpHashAttribs in hashAttribs)
104
+ {
105
+ String strTriggerName = strName + "_" + kvpHashAttribs.Key;
106
+ if ( !mapTriggers.containsKey(strTriggerName + "_delete") )
107
+ {
108
+ String strTrigger = "CREATE TRIGGER " + strTriggerPrefix + strTriggerName + "_delete BEFORE DELETE ON \"" + strName + "\" FOR EACH ROW \r\n"
109
+ +" BEGIN \r\n"
110
+ + " SELECT rhoOnDeleteSchemaRecord( OLD." + kvpHashAttribs.Key + ");\r\n"
111
+ +" END;\r\n"
112
+ +";";
113
+
114
+ db.createTrigger(strTrigger);
115
+ }else
116
+ mapTriggers[strTriggerName + "_delete"] = 1;
117
+
118
+ if ( !mapTriggers.containsKey(strTriggerName + "_update") )
119
+ {
120
+ String strTrigger = "CREATE TRIGGER " + strTriggerPrefix + strTriggerName + "_update BEFORE UPDATE ON \"" + strName + "\" FOR EACH ROW\r\n"
121
+ +" BEGIN \r\n"
122
+ + " SELECT rhoOnUpdateSchemaRecord( OLD." + kvpHashAttribs.Key + ", NEW." + kvpHashAttribs.Key + ");\r\n"
123
+ +" END;\r\n"
124
+ +";";
125
+
126
+ db.createTrigger(strTrigger);
127
+ }else
128
+ mapTriggers[strTriggerName + "_update"] = 1;
129
+
130
+ }
131
+ }
132
+
133
+ //Remove outdated triggers
134
+ foreach (KeyValuePair<string, int> kvp in mapTriggers)
135
+ {
136
+ if(kvp.Value != 0)
137
+ db.dropTrigger(strTriggerPrefix+kvp.Key.ToString());
138
+ }
77
139
  }
78
140
 
79
141
  static void loadAttrs(DBAdapter db, Hashtable< int, Hashtable<String,int> > mapAttrs, String strDBAttr,
@@ -54,5 +54,7 @@ namespace rho.db
54
54
 
55
55
  boolean isDbFileExists(String strPath);
56
56
  void createTriggers();
57
+ void createTrigger(String strSQL);
58
+ void dropTrigger(String strName);
57
59
  }
58
60
  }
@@ -107,6 +107,29 @@ namespace rho.db
107
107
  }
108
108
  }
109
109
 
110
+ public void createTrigger(String strSQL)
111
+ {
112
+ int res = Sqlite3.sqlite3_exec(m_db, strSQL, 0, 0, 0);
113
+ if (res != Sqlite3.SQLITE_OK)
114
+ {
115
+ Sqlite3.sqlite3_close(m_db);
116
+ m_db = null;
117
+ throw new DBException(res, "Cannot create trigger: " + strSQL);
118
+ }
119
+ }
120
+
121
+ public void dropTrigger(String strName)
122
+ {
123
+ String strSQL = "DROP TRIGGER " + strName + ";";
124
+ int res = Sqlite3.sqlite3_exec(m_db, strSQL, 0, 0, 0);
125
+ if (res != Sqlite3.SQLITE_OK)
126
+ {
127
+ Sqlite3.sqlite3_close(m_db);
128
+ m_db = null;
129
+ throw new DBException(res, "Cannot drop trigger: " + strName);
130
+ }
131
+ }
132
+
110
133
  void checkError()
111
134
  {
112
135
  int res = Sqlite3.sqlite3_errcode(m_db);
@@ -216,6 +239,10 @@ namespace rho.db
216
239
  DBAdapter.SyncBlob_DeleteCallback, null, null);
217
240
  Sqlite3.sqlite3_create_function(m_db, "rhoOnUpdateObjectRecord", 3, Sqlite3.SQLITE_ANY, 0,
218
241
  DBAdapter.SyncBlob_UpdateCallback, null, null);
242
+ Sqlite3.sqlite3_create_function(m_db, "rhoOnDeleteSchemaRecord", 1, Sqlite3.SQLITE_ANY, 0,
243
+ DBAdapter.SyncBlob_DeleteSchemaCallback, null, null);
244
+ Sqlite3.sqlite3_create_function(m_db, "rhoOnUpdateSchemaRecord", 2, Sqlite3.SQLITE_ANY, 0,
245
+ DBAdapter.SyncBlob_UpdateSchemaCallback, null, null);
219
246
 
220
247
  string[] ar2 = CRhoFile.enumDirectory("db");
221
248
 
@@ -68,8 +68,8 @@ namespace rho.logging
68
68
  {
69
69
  IDictionary<object, object> map = new Dictionary<object, object>();
70
70
  Hash values = new Hash(map);
71
- values.Add(MutableString.Create("url"), MutableString.Create(m_addrHost));
72
- values.Add(MutableString.Create("body"), MutableString.Create(strMsg));
71
+ values.Add(CRhoRuby.CreateSymbol("url"), MutableString.Create(m_addrHost));
72
+ values.Add(CRhoRuby.CreateSymbol("body"), MutableString.Create(strMsg));
73
73
  RhoParams p = new RhoParams(values);
74
74
  m_aHttp.addHttpCommand(new CAsyncHttp.HttpCommand("POST", p));
75
75
  }
@@ -100,9 +100,10 @@ namespace rho.net
100
100
  Hashtable<String, String>.Enumerator hashEnum = headers.GetEnumerator();
101
101
  while( hashEnum.MoveNext() )
102
102
  {
103
- String strName = hashEnum.Current.Key;
103
+ String strName = hashEnum.Current.Key.Replace(" ", "").Replace("-", "");
104
104
  String strValue = hashEnum.Current.Value;
105
- m_webRequest.Headers[strName.Replace("-", "")] = strValue;
105
+ m_webRequest.Headers[strName] = strValue;
106
+ if (strName == "ContentType") m_webRequest.ContentType = strValue;
106
107
  }
107
108
 
108
109
  }
@@ -510,7 +511,7 @@ namespace rho.net
510
511
  NetResponse pResp = new NetResponse(strRespBody != null ? strRespBody : "", nErrorCode );
511
512
  if (pResp.isSuccess())
512
513
  {
513
- if (m_strCookies == "" && m_strRespBody.Contains("rhoconnect_session"))
514
+ if (m_strCookies == "" && m_strRespBody != null && m_strRespBody.Contains("rhoconnect_session"))
514
515
  {
515
516
  m_strRespBody = m_strRespBody.Replace('{', ' ');
516
517
  m_strRespBody = m_strRespBody.Replace('}', ' ');
@@ -0,0 +1,160 @@
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
+ using Microsoft.Scripting.Utils;
28
+ using Microsoft.Scripting.Runtime;
29
+ using IronRuby.Runtime;
30
+ using IronRuby.Builtins;
31
+ using System;
32
+ using System.Runtime.InteropServices;
33
+ using Coding4Fun.Phone.Controls;
34
+ using System.Windows.Controls;
35
+ using System.Windows;
36
+ using rho.common;
37
+
38
+ namespace rho.rubyext
39
+ {
40
+ [RubyModule("Alert")]
41
+ public static class RhoAlert
42
+ {
43
+ private static RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() :
44
+ new RhoLogger("RhoAlert");
45
+ private static CRhoRuby RhoRuby { get { return CRhoRuby.Instance; } }
46
+ private static CRhodesApp RHODESAPP() { return CRhodesApp.Instance; }
47
+ private static MessagePrompt m_messagePrompt = null;
48
+ private static String m_callback = "";
49
+ private static int m_buttonId = 0;
50
+ private static String m_buttonTitle = "";
51
+
52
+ #region Private Implementation Details
53
+
54
+ #endregion
55
+
56
+ #region Private Instance & Singleton Methods
57
+
58
+ [RubyMethodAttribute("show_popup", RubyMethodAttributes.PublicSingleton)]
59
+ public static void ShowPopup(RubyModule/*!*/ self, Object args)
60
+ {
61
+ String message = "";
62
+ String title = "";
63
+ Object[] buttons = null;
64
+ object val = null;
65
+
66
+ if (args != null && args is MutableString)
67
+ {
68
+ message = ((MutableString)args).ToString();
69
+ buttons = new String[1];
70
+ buttons[0] = "Ok";
71
+ }
72
+ if (args != null && args is Hash && ((Hash)args).TryGetValue(CRhoRuby.CreateSymbol("title"), out val))
73
+ title = val.ToString();
74
+ if (args != null && args is Hash && ((Hash)args).TryGetValue(CRhoRuby.CreateSymbol("message"), out val))
75
+ message = val.ToString();
76
+ if (args != null && args is Hash && ((Hash)args).TryGetValue(CRhoRuby.CreateSymbol("callback"), out val))
77
+ m_callback = val.ToString();
78
+ if (args != null && args is Hash && ((Hash)args).TryGetValue(CRhoRuby.CreateSymbol("buttons"), out val) && val is RubyArray)
79
+ buttons = ((RubyArray)val).ToArray();
80
+
81
+ RHODESAPP().MainPage.Dispatcher.BeginInvoke(() =>
82
+ {
83
+ m_messagePrompt = new MessagePrompt
84
+ {
85
+ Title = title,
86
+ Message = message
87
+ };
88
+ m_messagePrompt.Completed += messagePrompt_Completed;
89
+ m_messagePrompt.ActionPopUpButtons.Clear();
90
+ for (int i = 0; buttons != null && i < buttons.Length; i++)
91
+ {
92
+ if (buttons[i] != null)
93
+ {
94
+ Button customButton = new Button();
95
+ if(buttons[i] is Hash)
96
+ {
97
+ ((Hash)buttons[i]).TryGetValue(CRhoRuby.CreateSymbol("title"), out val);
98
+ if(val != null)
99
+ customButton.Content = val;
100
+ }
101
+ else
102
+ customButton.Content = buttons[i];
103
+ customButton.Click += new RoutedEventHandler(customButton_Click);
104
+ m_messagePrompt.ActionPopUpButtons.Add(customButton);
105
+ }
106
+ }
107
+ m_messagePrompt.Show();
108
+ });
109
+
110
+ }
111
+
112
+ [RubyMethodAttribute("hide_popup", RubyMethodAttributes.PublicSingleton)]
113
+ public static void HidePopup(RubyModule/*!*/ self)
114
+ {
115
+ RHODESAPP().MainPage.Dispatcher.BeginInvoke(() =>
116
+ {
117
+ if (m_messagePrompt != null)
118
+ m_messagePrompt.Hide();
119
+ });
120
+ }
121
+
122
+ [RubyMethodAttribute("vibrate", RubyMethodAttributes.PublicSingleton)]
123
+ public static void Vibrate(RubyModule/*!*/ self, int duration)
124
+ {
125
+ }
126
+
127
+ [RubyMethodAttribute("play_file", RubyMethodAttributes.PublicSingleton)]
128
+ public static void PlayFile(RubyModule/*!*/ self, [NotNull]String/*!*/ fileName, [NotNull]String/*!*/ mediaType)
129
+ {
130
+ }
131
+
132
+ [RubyMethodAttribute("show_status", RubyMethodAttributes.PublicSingleton)]
133
+ public static void ShowStatus(RubyModule/*!*/ self, [NotNull]String/*!*/ title, [NotNull]String/*!*/ text, String/*!*/ hideLabel)
134
+ {
135
+ }
136
+
137
+ #endregion
138
+
139
+ private static void customButton_Click(object sender, RoutedEventArgs e)
140
+ {
141
+ if (m_messagePrompt != null)
142
+ {
143
+ m_buttonTitle = ((Button)sender).Content.ToString();
144
+ m_buttonId = m_messagePrompt.ActionPopUpButtons.IndexOf((Button)sender);
145
+ m_messagePrompt.Hide();
146
+ }
147
+ }
148
+
149
+ private static void messagePrompt_Completed(object sender, PopUpEventArgs<string, PopUpResult> e)
150
+ {
151
+ if (m_callback != "")
152
+ {
153
+ m_callback = RHODESAPP().canonicalizeRhoUrl(m_callback);
154
+ RhoClassFactory.createNetRequest().pushData(m_callback, "button_id="+m_buttonId.ToString()+"&button_title="+m_buttonTitle+"&rho_callback=1", null);
155
+ }
156
+ }
157
+
158
+
159
+ }
160
+ }
@@ -43,12 +43,24 @@ namespace rho.rubyext
43
43
  static CRhoRuby RhoRuby { get { return CRhoRuby.Instance; } }
44
44
 
45
45
  [RubyMethod("dosync", RubyMethodAttributes.PublicSingleton)]
46
- public static object dosync(RubyModule/*!*/ self)
46
+ public static object dosync(RubyModule/*!*/ self, RubyArray args)
47
47
  {
48
48
  object res = null;
49
49
  try
50
50
  {
51
- SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncAll, false));
51
+ boolean bShowStatus = true;
52
+ String query_params = "";
53
+ if ( args != null && args.Count > 0 )
54
+ {
55
+ String str = ((MutableString)args[0]).ToString();
56
+ //bShowStatus = args[0].Equals(RubyConstant.QTRUE)||"true".equalsIgnoreCase(str);
57
+ bShowStatus = "true".equalsIgnoreCase(str);
58
+ }
59
+
60
+ if (args != null && args.Count > 1)
61
+ query_params = ((MutableString)args[1]).ToString();
62
+
63
+ SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncAll, bShowStatus, query_params));
52
64
 
53
65
  res = SyncThread.getInstance().getRetValue();
54
66
  }
@@ -66,8 +78,8 @@ namespace rho.rubyext
66
78
  return res;
67
79
  }
68
80
 
69
- [RubyMethod("dosync", RubyMethodAttributes.PublicSingleton)]
70
- public static object dosync(RubyModule/*!*/ self, bool/*!*/ show_status_popup)
81
+ /*[RubyMethod("dosync", RubyMethodAttributes.PublicSingleton)]
82
+ public static object dosync(RubyModule self, bool show_status_popup)
71
83
  {
72
84
  object res = null;
73
85
  try
@@ -88,24 +100,44 @@ namespace rho.rubyext
88
100
  }
89
101
 
90
102
  return res;
91
- }
103
+ }*/
92
104
 
93
105
  [RubyMethod("dosync_source", RubyMethodAttributes.PublicSingleton)]
94
- public static object dosync_source(RubyModule/*!*/ self, [NotNull]object/*!*/ srcID)
106
+ public static object dosync_source(RubyModule/*!*/ self, RubyArray args)
95
107
  {
96
108
  object res = null;
97
109
  try
98
110
  {
99
111
  int nSrcID = 0;
100
112
  String strName = "";
101
- if (srcID is long)
113
+
114
+ if ( args[0] is long)
115
+ nSrcID = (int)(long)args[0];
116
+ else if (args[0] is int)
117
+ nSrcID = (int)args[0];
118
+ else
119
+ strName = ((MutableString)args[0]).ToString();
120
+
121
+ /*if (srcID is long)
102
122
  nSrcID = (int)(long)srcID;
103
123
  else if (srcID is int)
104
124
  nSrcID = (int)srcID;
105
125
  else
106
- strName = srcID.ToString();
126
+ strName = srcID.ToString();*/
127
+
128
+ boolean bShowStatus = true;
129
+ String query_params = "";
130
+ if ( args != null && args.Count > 1 )
131
+ {
132
+ String str = ((MutableString)args[1]).ToString();
133
+ //bShowStatus = args[0].Equals(RubyConstant.QTRUE)||"true".equalsIgnoreCase(str);
134
+ bShowStatus = "true".equalsIgnoreCase(str);
135
+ }
136
+
137
+ if (args != null && args.Count > 2)
138
+ query_params = ((MutableString)args[2]).ToString();
107
139
 
108
- SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncOne, strName, nSrcID, true));
140
+ SyncThread.getInstance().addQueueCommand(new SyncThread.SyncCommand(SyncThread.scSyncOne, strName, nSrcID, bShowStatus, query_params));
109
141
 
110
142
  res = SyncThread.getInstance().getRetValue();
111
143
  }
@@ -123,8 +155,8 @@ namespace rho.rubyext
123
155
  return res;
124
156
  }
125
157
 
126
- [RubyMethod("dosync_source", RubyMethodAttributes.PublicSingleton)]
127
- public static object dosync_source(RubyModule/*!*/ self, [NotNull]object/*!*/ srcID, bool/*!*/ show_status_popup)
158
+ /*[RubyMethod("dosync_source", RubyMethodAttributes.PublicSingleton)]
159
+ public static object dosync_source(RubyModule self, [NotNull]object srcID, bool show_status_popup)
128
160
  {
129
161
  object res = null;
130
162
  try
@@ -154,7 +186,7 @@ namespace rho.rubyext
154
186
  }
155
187
 
156
188
  return res;
157
- }
189
+ }*/
158
190
 
159
191
  [RubyMethod("dosearch", RubyMethodAttributes.PublicSingleton)]
160
192
  public static object dosearch(RubyModule/*!*/ self, [NotNull]RubyArray/*!*/ arSourcesR, [NotNull]String/*!*/ from, [NotNull]String/*!*/ strParams,