rhodes 3.3.2.beta.5 → 3.3.2.beta.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/CHANGELOG +1 -0
  2. data/Rakefile +4 -0
  3. data/doc/configuration.txt +2 -2
  4. data/doc/device-caps.txt +30 -17
  5. data/doc/ui.txt +24 -0
  6. data/lib/build/jake.rb +85 -2
  7. data/lib/framework/rho/rhoapplication.rb +14 -2
  8. data/platform/android/Rhodes/res/layout/datetime.xml +5 -5
  9. data/platform/android/Rhodes/src/com/rhomobile/rhodes/datetime/DateTimePickerScreen.java +2 -2
  10. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/AnnotationsOverlay.java +8 -2
  11. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/CalloutOverlay.java +88 -24
  12. data/platform/android/build/android.rake +27 -9
  13. data/platform/iphone/Classes/GeoLocation/LocationController.m +3 -0
  14. data/platform/iphone/rbuild/iphone.rake +6 -2
  15. data/platform/shared/common/RhodesApp.cpp +6 -1
  16. data/platform/shared/common/ThreadQueue.cpp +7 -1
  17. data/platform/shared/common/ThreadQueue.h +5 -1
  18. data/platform/shared/logging/RhoLog.cpp +4 -1
  19. data/platform/shared/logging/RhoLogConf.cpp +25 -11
  20. data/platform/shared/logging/RhoLogConf.h +4 -2
  21. data/platform/shared/logging/RhoLogSink.cpp +21 -15
  22. data/platform/shared/logging/RhoLogSink.h +17 -8
  23. data/platform/shared/net/AsyncHttp.cpp +16 -10
  24. data/platform/shared/net/AsyncHttp.h +3 -2
  25. data/platform/wm/build/wm.rake +27 -2
  26. data/platform/wm/tools/detool/detool.cpp +4 -8
  27. data/platform/wp7/build/wp.rake +2 -34
  28. data/rakefile.rb +4 -0
  29. data/res/build-tools/detool.exe +0 -0
  30. data/res/generators/templates/spec/app/spec_runner.rb +8 -2
  31. data/spec/framework_spec/app/spec_runner.rb +22 -6
  32. data/version +1 -1
  33. metadata +4 -4
@@ -60,7 +60,8 @@ ANDROID_PERMISSIONS = {
60
60
  'calendar' => ['READ_CALENDAR', 'WRITE_CALENDAR'],
61
61
  'sdcard' => 'WRITE_EXTERNAL_STORAGE',
62
62
  'push' => proc do |manifest| add_push(manifest) end,
63
- 'motorola' => nil,
63
+ 'motorola' => ['SYSTEM_ALERT_WINDOW', 'BROADCAST_STICKY', proc do |manifest| add_motosol_sdk(manifest) end],
64
+ 'motoroladev' => ['SYSTEM_ALERT_WINDOW', 'BROADCAST_STICKY', proc do |manifest| add_motosol_sdk(manifest) end],
64
65
  'webkit_browser' => nil
65
66
  }
66
67
 
@@ -109,6 +110,14 @@ def add_push(manifest)
109
110
  end
110
111
  end
111
112
 
113
+ def add_motosol_sdk(manifest)
114
+ uses_library = REXML::Element.new 'uses-library'
115
+ uses_library.add_attribute 'android:name', 'com.motorolasolutions.scanner'
116
+ manifest.elements.each('application') do |app|
117
+ app.add uses_library
118
+ end
119
+ end
120
+
112
121
  def set_app_name_android(newname)
113
122
  puts "set_app_name"
114
123
  $stdout.flush
@@ -154,17 +163,22 @@ def set_app_name_android(newname)
154
163
 
155
164
  caps_proc = []
156
165
  # Default permissions. Need to be always enabled.
157
- caps = ['INTERNET', 'PERSISTENT_ACTIVITY', 'WAKE_LOCK', 'SYSTEM_ALERT_WINDOW']
166
+ caps = ['INTERNET', 'PERSISTENT_ACTIVITY', 'WAKE_LOCK']
158
167
  $app_config["capabilities"].each do |cap|
159
168
  cap = ANDROID_PERMISSIONS[cap]
160
169
  next if cap.nil?
161
- if cap.is_a? Proc
162
- caps_proc << cap
163
- next
170
+ cap = [cap] unless cap.is_a? Array
171
+
172
+ cap.each do |cap_item|
173
+ if cap_item.is_a? Proc
174
+ caps_proc << cap_item
175
+ next
176
+ end
177
+ if cap_item.is_a? String
178
+ caps << cap_item
179
+ next
180
+ end
164
181
  end
165
- cap = [cap] if cap.is_a? String
166
- cap = [] unless cap.is_a? Array
167
- caps += cap
168
182
  end
169
183
  caps.uniq!
170
184
 
@@ -564,7 +578,11 @@ namespace "config" do
564
578
  $app_config["capabilities"] += ANDROID_CAPS_ALWAYS_ENABLED
565
579
  $app_config["capabilities"].map! { |cap| cap.is_a?(String) ? cap : nil }.delete_if { |cap| cap.nil? }
566
580
  $use_google_addon_api = true unless $app_config["capabilities"].index("push").nil?
567
- $use_motosol_barcode_api = false #true unless $app_config["extensions"].index("barcode").nil?
581
+
582
+ unless $app_config['capabilities'].index('motorola').nil? and $app_config['capabilities'].index('motoroladev').nil?
583
+ $use_motosol_barcode_api = true if $app_config['extensions'].index('barcode') or $app_config['extensions'].index('barcode-moto')
584
+ raise 'Cannot use Motorola SDK addon and Google SDK addon together!' if $use_google_addon_api
585
+ end
568
586
 
569
587
  $applog_path = nil
570
588
  $applog_file = $app_config["applog"]
@@ -65,6 +65,7 @@ static LocationController *sharedLC = nil;
65
65
  CFRunLoopTimerSetNextFireDate(_timer, CFAbsoluteTimeGetCurrent() + timeOutInSeconds);
66
66
  }
67
67
 
68
+ _locationManager.delegate = self; // Tells the location manager to send updates to this object
68
69
  [_locationManager startUpdatingLocation];
69
70
  return true;
70
71
  }
@@ -105,6 +106,7 @@ static LocationController *sharedLC = nil;
105
106
  if (!_locationManager)
106
107
  return;
107
108
  [_locationManager stopUpdatingLocation];
109
+ _locationManager.delegate = nil;
108
110
 
109
111
  // Get rid of the timer, if it still exists
110
112
  if (_timer != NULL) {
@@ -277,6 +279,7 @@ int rho_geo_known_position() {
277
279
 
278
280
  void rho_geoimpl_settimeout(int nTimeoutSec)
279
281
  {
282
+
280
283
  }
281
284
 
282
285
  void rho_geoimpl_turngpsoff()
@@ -1061,6 +1061,7 @@ namespace "run" do
1061
1061
 
1062
1062
  mkdir_p File.join($simrhodes, "Documents")
1063
1063
  mkdir_p File.join($simrhodes, "Library", "Preferences")
1064
+ mkdir_p File.join($simrhodes, "Library", "Caches", "Private Documents")
1064
1065
 
1065
1066
  rm_rf File.join($simrhodes, 'rhorunner.app')
1066
1067
  cp_r rhorunner, $simrhodes
@@ -1101,7 +1102,8 @@ namespace "run" do
1101
1102
  rhorunner = File.join($startdir, $config["build"]["iphonepath"],"build/#{$configuration}-iphonesimulator/rhorunner.app")
1102
1103
  commandis = iphonesim + ' launch "' + rhorunner + '" ' + $sdkver.gsub(/([0-9]\.[0-9]).*/,'\1') + ' ' + $emulatortarget
1103
1104
 
1104
- Thread.new {
1105
+ thr = Thread.new do
1106
+ puts 'start thread with execution of application'
1105
1107
  if ($emulatortarget != 'iphone') && ($emulatortarget != 'ipad')
1106
1108
  puts 'use old execution way - just open iPhone Simulator'
1107
1109
  system("open \"#{$sim}/iPhone Simulator.app\"")
@@ -1109,7 +1111,9 @@ namespace "run" do
1109
1111
  puts 'use iphonesim tool - open iPhone Simulator and execute our application, also support device family (iphone/ipad)'
1110
1112
  system(commandis)
1111
1113
  end
1112
- }
1114
+ end
1115
+
1116
+ thr.join
1113
1117
 
1114
1118
  puts "end build iphone app"
1115
1119
  exit
@@ -85,6 +85,7 @@ public:
85
85
 
86
86
  public:
87
87
  CAppCallbacksQueue();
88
+ CAppCallbacksQueue(LogCategory logCat);
88
89
  ~CAppCallbacksQueue();
89
90
 
90
91
  //void call(callback_t type);
@@ -303,7 +304,9 @@ CRhodesApp::CRhodesApp(const String& strRootPath, const String& strUserPath)
303
304
  #endif
304
305
 
305
306
  initAppUrls();
306
-
307
+
308
+ LOGCONF().initRemoteLog();
309
+
307
310
  initHttpServer();
308
311
 
309
312
  getSplashScreen().init();
@@ -357,6 +360,8 @@ CRhodesApp::~CRhodesApp(void)
357
360
  {
358
361
  stopApp();
359
362
 
363
+ LOGCONF().closeRemoteLog();
364
+
360
365
  #ifdef OS_WINCE
361
366
  WSACleanup();
362
367
  #endif
@@ -28,9 +28,12 @@
28
28
 
29
29
  //1. when stop thread - cancel current command. Add cancelCurrentCommand to ThreadQueue and call it from stop
30
30
 
31
+
31
32
  namespace rho {
32
33
  namespace common {
33
34
 
35
+ unsigned int CThreadQueue::m_logThreadId = 0;
36
+
34
37
  CThreadQueue::CThreadQueue() : CRhoThread()
35
38
  {
36
39
  m_nPollInterval = QUEUE_POLL_INTERVAL_SECONDS;
@@ -68,7 +71,7 @@ int CThreadQueue::getCommandsCount() {
68
71
 
69
72
  void CThreadQueue::addQueueCommandInt(IQueueCommand* pCmd)
70
73
  {
71
- LOG(INFO) + "addCommand: " + pCmd->toString();
74
+ LOG(INFO) + "addCommand: " + pCmd->toString();
72
75
 
73
76
  synchronized(m_mxStackCommands);
74
77
 
@@ -136,6 +139,9 @@ void CThreadQueue::processCommandBase(IQueueCommand* pCmd)
136
139
 
137
140
  void CThreadQueue::run()
138
141
  {
142
+ if(__rhoCurrentCategory.getName() == "NO_LOGGING")
143
+ m_logThreadId = getThreadID();
144
+
139
145
  LOG(INFO) + "Starting main routine...";
140
146
 
141
147
  int nLastPollInterval = getLastPollInterval();
@@ -62,10 +62,12 @@ private:
62
62
  IQueueCommand* m_pCurCmd;
63
63
 
64
64
  boolean m_bNoThreaded;
65
+ static unsigned int m_logThreadId;
66
+
65
67
  public:
66
68
  CThreadQueue();
67
69
 
68
- ~CThreadQueue(void);
70
+ virtual ~CThreadQueue(void);
69
71
 
70
72
  virtual void addQueueCommand(IQueueCommand* pCmd);
71
73
  virtual void addQueueCommandToFront(IQueueCommand* pCmd);
@@ -84,6 +86,8 @@ public:
84
86
  LinkedListPtr<IQueueCommand*>& getCommands(){ return m_stackCommands; }
85
87
 
86
88
  int getCommandsCount();
89
+
90
+ static unsigned int getLogThreadId() {return m_logThreadId;}
87
91
  protected:
88
92
  virtual int getLastPollInterval(){ return 0;}
89
93
  virtual void processCommand(IQueueCommand* pCmd) = 0;
@@ -28,6 +28,7 @@
28
28
  #include "common/RhoFilePath.h"
29
29
  #include "common/RhoTime.h"
30
30
  #include "common/RhoSystem.h"
31
+ #include "common/ThreadQueue.h"
31
32
 
32
33
  rho::LogCategory __rhoCurrentCategory;
33
34
 
@@ -44,7 +45,9 @@ LogMessage::LogMessage(const char* file, int line, LogSeverity severity, LogSett
44
45
  }
45
46
 
46
47
  bool LogMessage::isEnabled()const{
47
- if ( m_severity >= getLogConf().getMinSeverity() ){
48
+ if(m_category.getName() == "NO_LOGGING" || common::CThreadQueue::getLogThreadId() == common::CSystem::getThreadID()) return false;
49
+
50
+ if ( m_severity >= getLogConf().getMinSeverity() ){
48
51
  if ( m_category.isEmpty() || m_severity >= L_ERROR )
49
52
  return true;
50
53
 
@@ -51,7 +51,7 @@ LogSettings::LogSettings(){
51
51
  m_nMaxLogFileSize = 0;
52
52
  m_bLogPrefix = true;
53
53
 
54
- m_strLogHost = "PPP_PEER";
54
+ //m_strLogHost = "PPP_PEER";
55
55
 
56
56
  m_pFileSink = new CLogFileSink(*this);
57
57
  m_pOutputSink = new CLogOutputSink(*this);
@@ -62,17 +62,34 @@ LogSettings::LogSettings(){
62
62
  LogSettings::~LogSettings(){
63
63
  delete m_pFileSink;
64
64
  delete m_pOutputSink;
65
- delete m_pSocketSink;
65
+ if(m_pSocketSink)
66
+ delete m_pSocketSink;
66
67
  }
67
68
 
68
- void LogSettings::setLogPort(const char* szLogPort)
69
+ void LogSettings::closeRemoteLog()
69
70
  {
70
- setLogToSocket(true);
71
+ if(m_pSocketSink)
72
+ {
73
+ delete m_pSocketSink;
74
+ m_pSocketSink = 0;
75
+ }
76
+ }
71
77
 
72
- m_strLogPort = rho::String(szLogPort);
78
+ void LogSettings::initRemoteLog()
79
+ {
80
+ #ifdef OS_PLATFORM_MOTCE
81
+ //TODO: remote log prevent loading app - stuck on loading.png
82
+ OSVERSIONINFO osv = {0};
83
+ osv.dwOSVersionInfoSize = sizeof(osv);
84
+ if (GetVersionEx(&osv) && osv.dwMajorVersion == 5)
85
+ return;
86
+ #endif
73
87
 
74
- delete m_pSocketSink;
75
- m_pSocketSink = new CLogSocketSink(*this);
88
+ m_strLogHost = RHOCONF().getString("rhologhost");
89
+ m_strLogPort = RHOCONF().getString("rhologport");
90
+
91
+ if(!m_pSocketSink && m_strLogHost != "" && m_strLogPort != "")
92
+ m_pSocketSink = new CLogSocketSink(*this);
76
93
  }
77
94
 
78
95
  void LogSettings::getLogTextW(StringW& strTextW)
@@ -173,7 +190,7 @@ void LogSettings::sinkLogMessage( String& strMsg ){
173
190
  if ( isLogToOutput() )
174
191
  m_pOutputSink->writeLogMessage(strMsg);
175
192
 
176
- if ( isLogToSocket() )
193
+ if (m_pSocketSink)
177
194
  m_pSocketSink->writeLogMessage(strMsg);
178
195
  }
179
196
 
@@ -266,9 +283,6 @@ void rho_logconf_Init_with_separate_user_path(const char* szRootPath, const char
266
283
  rho_conf_Init_with_separate_user_path(szRootPath, szUserPath);
267
284
 
268
285
  LOGCONF().loadFromConf(RHOCONF());
269
- if ( szLogPort != NULL && *szLogPort )
270
- LOGCONF().setLogPort(szLogPort);
271
-
272
286
  }
273
287
 
274
288
  void rho_logconf_Init(const char* szRootPath, const char* szLogPort){
@@ -39,6 +39,7 @@ namespace common{ class RhoSettings; }
39
39
  class LogCategory;
40
40
 
41
41
  struct ILogSink{
42
+ virtual ~ILogSink(){}
42
43
  virtual void writeLogMessage( String& strMsg ) = 0;
43
44
  virtual int getCurPos() = 0;
44
45
  virtual void clear() = 0;
@@ -102,8 +103,9 @@ public:
102
103
  void setLogHost(const char* szLogHost) { m_strLogHost = rho::String(szLogHost); }
103
104
 
104
105
  const String& getLogPort() const { return m_strLogPort; }
105
- void setLogPort(const char* szLogPort);
106
-
106
+ void initRemoteLog();
107
+ void closeRemoteLog();
108
+
107
109
  void setEnabledCategories( const char* szCatList );
108
110
  void setDisabledCategories( const char* szCatList );
109
111
  const String& getEnabledCategories(){ return m_strEnabledCategories; }
@@ -163,27 +163,33 @@ void CLogOutputSink::writeLogMessage( String& strMsg )
163
163
  #endif
164
164
  }
165
165
 
166
- CLogSocketSink::CLogSocketSink(const LogSettings& oSettings)
167
- : m_oLogConf(oSettings)
168
- , m_logNetClient(0)
166
+ CLogSocketSink::CLogSocketSink(const LogSettings& oSettings)
169
167
  {
170
- m_hostName = oSettings.getLogHost();
171
- m_hostPort = oSettings.getLogPort();
168
+ m_addrHost = "http://"+oSettings.getLogHost() + ":" + oSettings.getLogPort();
169
+
170
+ CThreadQueue::setLogCategory(LogCategory("NO_LOGGING"));
171
+ setPollInterval(QUEUE_POLL_INTERVAL_INFINITE);
172
+ start(epLow);
173
+ }
174
+
175
+ CLogSocketSink::~CLogSocketSink()
176
+ {
177
+ //wait till all commands will be sent to server
178
+ CRhoThread::stop(-1);
172
179
  }
173
180
 
174
181
  void CLogSocketSink::writeLogMessage( String& strMsg )
175
182
  {
176
- if (!m_logNetClient)
177
- {
178
- m_logNetClient = new rho::net::RawSocket(m_hostName, m_hostPort);
179
- }
180
-
181
- if (!m_logNetClient->isInit())
182
- {
183
- m_logNetClient->init();
184
- }
183
+ addQueueCommand(new LogCommand(m_addrHost.c_str(), strMsg.c_str()));
184
+ }
185
+
186
+ void CLogSocketSink::processCommand(IQueueCommand* pCmd)
187
+ {
188
+ LogCommand *cmd = (LogCommand *)pCmd;
189
+ if (!cmd)
190
+ return;
185
191
 
186
- m_logNetClient->send(strMsg);
192
+ getNetRequest().doRequest( "POST", cmd->m_url, cmd->m_body, 0, 0 );
187
193
  }
188
194
 
189
195
  }
@@ -29,6 +29,7 @@
29
29
 
30
30
  #include "RhoLogConf.h"
31
31
  #include "net/RawSocket.h"
32
+ #include "common/RhodesApp.h"
32
33
 
33
34
  namespace rho {
34
35
  namespace common {
@@ -68,21 +69,29 @@ public:
68
69
  void clear(){}
69
70
  };
70
71
 
72
+ class CLogSocketSink : public ILogSink, common::CThreadQueue{
73
+ String m_addrHost;
71
74
 
72
- class CLogSocketSink : public ILogSink{
73
- const LogSettings& m_oLogConf;
74
-
75
- rho::net::RawSocket *m_logNetClient;
76
-
77
- String m_hostName;
78
- String m_hostPort;
79
75
  public:
80
76
  CLogSocketSink(const LogSettings& oSettings);
81
- virtual ~CLogSocketSink() { delete m_logNetClient; }
77
+ virtual ~CLogSocketSink();
82
78
 
83
79
  void writeLogMessage( String& strMsg );
84
80
  int getCurPos(){ return -1; }
85
81
  void clear(){}
82
+
83
+ struct LogCommand : public IQueueCommand
84
+ {
85
+ String m_url;
86
+ String m_body;
87
+ LogCommand(String url, String body) : m_url(url), m_body(body) {}
88
+
89
+ boolean equals(IQueueCommand const &) {return false;}
90
+ String toString() {return "";}
91
+ };
92
+
93
+ private:
94
+ void processCommand(IQueueCommand* pCmd);
86
95
  };
87
96
 
88
97
  }
@@ -58,7 +58,7 @@ CAsyncHttp* CAsyncHttp::m_pInstance = 0;
58
58
 
59
59
  CAsyncHttp::CAsyncHttp() : CThreadQueue()
60
60
  {
61
- CThreadQueue::setLogCategory(getLogCategory());
61
+ CThreadQueue::setLogCategory(getLogCategory());
62
62
 
63
63
  setPollInterval(QUEUE_POLL_INTERVAL_INFINITE);
64
64
  }
@@ -71,17 +71,18 @@ CAsyncHttp::~CAsyncHttp(void)
71
71
 
72
72
  unsigned long CAsyncHttp::addHttpCommand(IQueueCommand* pCmd)
73
73
  {
74
- if ( ((CHttpCommand*)pCmd)->m_strCallback.length()==0)
74
+ if (((CHttpCommand*)pCmd)->m_strCallback.length()==0)
75
75
  {
76
76
  processCommandBase(pCmd);
77
77
  unsigned long ret = ((CHttpCommand*)pCmd)->getRetValue();
78
78
  delete pCmd;
79
79
  return ret;
80
80
  }
81
+
82
+ CThreadQueue::addQueueCommand(pCmd);
81
83
 
82
- CThreadQueue::addQueueCommand(pCmd);
83
- start(epLow);
84
-
84
+ start(epLow);
85
+
85
86
  return ((CHttpCommand*)pCmd)->getRetValue();
86
87
  }
87
88
 
@@ -145,9 +146,9 @@ void CAsyncHttp::CHttpCommand::execute()
145
146
  resp = getNet().doRequest( m_params.getString("http_command", "GET").c_str(),
146
147
  m_params.getString("url"), m_params.getString("body"), null, &m_mapHeaders);
147
148
  break;
148
- case hcPost:
149
+ case hcPost:
149
150
  resp = getNet().doRequest(m_params.getString("http_command", "POST").c_str(),
150
- m_params.getString("url"), m_params.getString("body"), null, &m_mapHeaders);
151
+ m_params.getString("url"), m_params.getString("body"), null, &m_mapHeaders);
151
152
  break;
152
153
 
153
154
  case hcDownload:
@@ -215,8 +216,13 @@ void CAsyncHttp::CHttpCommand::execute()
215
216
 
216
217
  unsigned long CAsyncHttp::CHttpCommand::getRetValue()
217
218
  {
218
- if ( m_strCallback.length() == 0 )
219
- return rho_ruby_create_string(m_strResBody.c_str());
219
+ if ( m_strCallback.length() == 0 )
220
+ {
221
+ if(getLogCategory().getName() == "NO_LOGGING")
222
+ return atoi(m_strResBody.c_str());
223
+ else
224
+ return rho_ruby_create_string(m_strResBody.c_str());
225
+ }
220
226
 
221
227
  return rho_ruby_get_NIL();
222
228
  }
@@ -241,7 +247,7 @@ String CAsyncHttp::CHttpCommand::makeHeadersString()
241
247
 
242
248
  void CAsyncHttp::CHttpCommand::callNotify(NetResponse& resp, int nError )
243
249
  {
244
- m_strResBody = "rho_callback=1";
250
+ m_strResBody = "rho_callback=1";
245
251
  m_strResBody += "&status=";
246
252
  if ( nError > 0 )
247
253
  {