rhodes 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +10 -0
- data/lib/framework/rho/rhoerror.rb +4 -0
- data/lib/framework/rhodes.rb +2 -2
- data/lib/framework/rhom/rhom.rb +21 -1
- data/lib/framework/version.rb +2 -2
- data/lib/rhodes.rb +2 -2
- data/platform/android/Rhodes/AndroidManifest.xml +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +21 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesInstance.java +1 -1
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +10 -0
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +1 -1
- data/platform/bb/rhodes/src/com/rho/rubyext/GeoLocation.java +2 -2
- data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +4 -2
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +52 -11
- data/platform/iphone/Classes/NativeBar.m +37 -18
- data/platform/iphone/Classes/Rhodes.h +2 -0
- data/platform/iphone/Classes/Rhodes.m +27 -8
- data/platform/iphone/Classes/SimpleMainView.h +7 -5
- data/platform/iphone/Classes/SimpleMainView.m +155 -36
- data/platform/iphone/Classes/TabbedMainView.h +2 -4
- data/platform/iphone/Classes/TabbedMainView.m +12 -10
- data/platform/iphone/Classes/WebView.m +1 -0
- data/platform/iphone/Info.plist +7 -1
- data/platform/iphone/icon114.png +0 -0
- data/platform/iphone/icon57.png +0 -0
- data/platform/iphone/icon72.png +0 -0
- data/platform/iphone/rbuild/iphone.rake +102 -16
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +12 -0
- data/platform/shared/common/IRhoThreadImpl.h +1 -1
- data/platform/shared/common/PosixThreadImpl.cpp +17 -22
- data/platform/shared/common/PosixThreadImpl.h +1 -1
- data/platform/shared/common/RhoThread.cpp +7 -3
- data/platform/shared/common/RhoThread.h +21 -7
- data/platform/shared/common/RhodesApp.cpp +13 -9
- data/platform/shared/common/RhodesApp.h +1 -1
- data/platform/shared/common/ThreadQueue.cpp +6 -4
- data/platform/shared/rubyJVM/src/com/rho/IRhoRubyHelper.java +2 -0
- data/platform/shared/rubyJVM/src/com/rho/RhoThread.java +18 -8
- data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +70 -2
- data/platform/shared/rubyJVM/src/com/rho/ThreadQueue.java +143 -0
- data/platform/shared/rubyJVM/src/com/rho/sync/ClientRegister.java +15 -5
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +42 -36
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncNotify.java +63 -20
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java +4 -4
- data/platform/shared/rubyJVM/src/com/rho/sync/SyncThread.java +12 -2
- data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RhoSupport.java +9 -3
- data/platform/shared/sync/ClientRegister.cpp +11 -3
- data/platform/shared/sync/ClientRegister.h +1 -0
- data/platform/shared/sync/SyncEngine.cpp +38 -35
- data/platform/shared/sync/SyncEngine.h +2 -1
- data/platform/shared/sync/SyncNotify.cpp +53 -20
- data/platform/shared/sync/SyncNotify.h +9 -2
- data/platform/shared/sync/SyncSource.cpp +3 -3
- data/platform/shared/sync/SyncSource.h +1 -1
- data/platform/shared/sync/SyncThread.cpp +9 -2
- data/platform/wm/rhodes/Alert.cpp +35 -21
- data/platform/wm/rhodes/Alert.h +11 -2
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.cpp +11 -12
- data/platform/wm/rhodes/rho/common/RhoThreadImpl.h +2 -0
- data/res/generators/templates/application/build.yml +1 -1
- data/rhodes.gemspec +2 -2
- data/spec/framework_spec/rhoconfig.txt +1 -0
- data/spec/phone_spec/rhoconfig.txt +2 -0
- metadata +8 -5
- data/Manifest.txt +0 -5333
| @@ -41,7 +41,7 @@ private: | |
| 41 41 | 
             
                int m_currentTabIndex;
         | 
| 42 42 | 
             
                String m_currentUrls[5];
         | 
| 43 43 |  | 
| 44 | 
            -
                String m_strAppBackUrl;
         | 
| 44 | 
            +
                String m_strAppBackUrl, m_strAppBackUrlOrig;
         | 
| 45 45 | 
             
                Vector<ICallbackObject*> m_arCallbackObjects;
         | 
| 46 46 | 
             
                rubyext::CGeoLocation m_oGeoLocation;
         | 
| 47 47 | 
             
                CSplashScreen m_oSplashScreen;
         | 
| @@ -49,7 +49,7 @@ void CThreadQueue::run() | |
| 49 49 | 
             
            	LOG(INFO) + "Starting main routine...";
         | 
| 50 50 |  | 
| 51 51 | 
             
            	int nLastPollInterval = getLastPollInterval();
         | 
| 52 | 
            -
            	while( ! | 
| 52 | 
            +
            	while( !isStopping() )
         | 
| 53 53 | 
             
            	{
         | 
| 54 54 | 
             
                    unsigned int nWait = m_nPollInterval > 0 ? m_nPollInterval : QUEUE_POLL_INTERVAL_INFINITE;
         | 
| 55 55 |  | 
| @@ -62,16 +62,18 @@ void CThreadQueue::run() | |
| 62 62 | 
             
                            nWait = nWait2;
         | 
| 63 63 | 
             
                    }
         | 
| 64 64 |  | 
| 65 | 
            -
                    if ( nWait >= 0 && ! | 
| 65 | 
            +
                    if ( nWait >= 0 && !isStopping() && isNoCommands() )
         | 
| 66 66 | 
             
            		{
         | 
| 67 67 | 
             
                        LOG(INFO) + "ThreadQueue blocked for " + nWait + " seconds...";
         | 
| 68 68 | 
             
                        wait(nWait);
         | 
| 69 69 | 
             
                    }
         | 
| 70 70 | 
             
                    nLastPollInterval = 0;
         | 
| 71 71 |  | 
| 72 | 
            -
                    if ( ! | 
| 72 | 
            +
                    if ( !isStopping() )
         | 
| 73 73 | 
             
                		processCommands();
         | 
| 74 74 | 
             
            	}
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                LOG(INFO) + "Thread shutdown";
         | 
| 75 77 | 
             
            }
         | 
| 76 78 |  | 
| 77 79 | 
             
            boolean CThreadQueue::isNoCommands()
         | 
| @@ -87,7 +89,7 @@ boolean CThreadQueue::isNoCommands() | |
| 87 89 |  | 
| 88 90 | 
             
            void CThreadQueue::processCommands()//throws Exception
         | 
| 89 91 | 
             
            {
         | 
| 90 | 
            -
            	while(! | 
| 92 | 
            +
            	while(!isStopping() && !isNoCommands())
         | 
| 91 93 | 
             
            	{
         | 
| 92 94 | 
             
            		common::CAutoPtr<CQueueCommand> pCmd = null;
         | 
| 93 95 | 
             
                	{
         | 
| @@ -6,16 +6,24 @@ public class RhoThread extends Thread | |
| 6 6 | 
             
            		new RhoLogger("RhoThread");
         | 
| 7 7 |  | 
| 8 8 | 
             
            	public final static int epNormal = 0, epHigh = 1, epLow = 2;
         | 
| 9 | 
            +
                static final int TS_NONE = 0;
         | 
| 10 | 
            +
                static final int TS_WAIT = 1;
         | 
| 11 | 
            +
                static final int TS_STOPPING = 2;
         | 
| 12 | 
            +
                //static final int TS_RUNNING = 4;
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                int m_nState;
         | 
| 15 | 
            +
            	
         | 
| 9 16 | 
             
            	private Object m_syncObj = new Object();
         | 
| 10 | 
            -
            	boolean m_isInWaitState;
         | 
| 11 | 
            -
            	protected boolean m_bStop = false;
         | 
| 12 17 |  | 
| 13 18 | 
             
                public RhoThread(RhoClassFactory factory)
         | 
| 14 19 | 
             
                {
         | 
| 15 | 
            -
                	 | 
| 20 | 
            +
                	m_nState = TS_NONE;
         | 
| 16 21 | 
             
                }
         | 
| 17 22 |  | 
| 18 23 | 
             
                public Object getSyncObject(){ return m_syncObj; }
         | 
| 24 | 
            +
                public boolean isStopping(){return (m_nState&TS_STOPPING) != 0;}
         | 
| 25 | 
            +
                public boolean isWaiting(){return (m_nState&TS_WAIT) != 0;}
         | 
| 26 | 
            +
                //public boolean isRunning(){return (m_nState&TS_RUNNING) != 0;}
         | 
| 19 27 |  | 
| 20 28 | 
             
                public void start(int ePriority)
         | 
| 21 29 | 
             
                {
         | 
| @@ -35,7 +43,7 @@ public class RhoThread extends Thread | |
| 35 43 |  | 
| 36 44 | 
             
                public void stop(int nTimeoutToKill)
         | 
| 37 45 | 
             
                { 
         | 
| 38 | 
            -
                	 | 
| 46 | 
            +
                	m_nState |= TS_STOPPING;
         | 
| 39 47 | 
             
                	stopWait();
         | 
| 40 48 |  | 
| 41 49 | 
             
            		try{
         | 
| @@ -51,21 +59,23 @@ public class RhoThread extends Thread | |
| 51 59 |  | 
| 52 60 | 
             
            		}catch(Exception e){
         | 
| 53 61 | 
             
            			LOG.ERROR("stop failed", e);
         | 
| 62 | 
            +
            		}finally
         | 
| 63 | 
            +
            		{
         | 
| 64 | 
            +
            			m_nState &= ~TS_STOPPING;
         | 
| 54 65 | 
             
            		}
         | 
| 55 | 
            -
                	
         | 
| 56 66 | 
             
                }
         | 
| 57 67 |  | 
| 58 68 | 
             
                public void wait(int nTimeout)
         | 
| 59 69 | 
             
                {
         | 
| 60 70 | 
             
            		synchronized (m_syncObj) {
         | 
| 61 71 | 
             
            			try{
         | 
| 62 | 
            -
            				 | 
| 72 | 
            +
            				m_nState |= TS_WAIT;
         | 
| 63 73 | 
             
            				m_syncObj.wait(nTimeout*1000);
         | 
| 64 74 | 
             
            			}catch(Exception e)
         | 
| 65 75 | 
             
            			{
         | 
| 66 76 | 
             
            				LOG.ERROR("wait failed", e);
         | 
| 67 77 | 
             
            			}finally{
         | 
| 68 | 
            -
            				 | 
| 78 | 
            +
            				m_nState &= ~TS_WAIT;
         | 
| 69 79 | 
             
            			}
         | 
| 70 80 | 
             
            		}
         | 
| 71 81 |  | 
| @@ -74,7 +84,7 @@ public class RhoThread extends Thread | |
| 74 84 | 
             
                public void stopWait()
         | 
| 75 85 | 
             
                {
         | 
| 76 86 | 
             
            		synchronized (m_syncObj) {
         | 
| 77 | 
            -
            	    	if (  | 
| 87 | 
            +
            	    	if ( isWaiting() )
         | 
| 78 88 | 
             
            	    		m_syncObj.notifyAll();
         | 
| 79 89 | 
             
                	}    	
         | 
| 80 90 | 
             
                }
         | 
| @@ -13,7 +13,8 @@ public class RhodesApp | |
| 13 13 | 
             
            	static RhodesApp m_pInstance;
         | 
| 14 14 |  | 
| 15 15 | 
             
                private String m_strRhoRootPath, m_strBlobsDirPath, m_strDBDirPath;
         | 
| 16 | 
            -
            	private String m_strHomeUrl;
         | 
| 16 | 
            +
            	private String m_strStartUrl, m_strHomeUrl;
         | 
| 17 | 
            +
            	private String m_strAppBackUrl = "", m_strAppBackUrlOrig = "";
         | 
| 17 18 |  | 
| 18 19 | 
             
                Vector/*<unsigned long>*/ m_arCallbackObjects = new Vector();
         | 
| 19 20 | 
             
                private SplashScreen m_oSplashScreen = new SplashScreen();
         | 
| @@ -27,6 +28,8 @@ public class RhodesApp | |
| 27 28 | 
             
                int m_currentTabIndex = 0;
         | 
| 28 29 | 
             
                String[] m_currentUrls = new String[5];
         | 
| 29 30 |  | 
| 31 | 
            +
                String getAppBackUrl(){return m_strAppBackUrl;}
         | 
| 32 | 
            +
             | 
| 30 33 | 
             
                public static RhodesApp Create(String strRootPath)
         | 
| 31 34 | 
             
                {
         | 
| 32 35 | 
             
                    if ( m_pInstance != null ) 
         | 
| @@ -236,5 +239,70 @@ public class RhodesApp | |
| 236 239 | 
             
                	{
         | 
| 237 240 | 
             
                		LOG.ERROR("Save current location failed.", exc);
         | 
| 238 241 | 
             
                	}
         | 
| 239 | 
            -
            	} | 
| 242 | 
            +
            	}
         | 
| 243 | 
            +
                
         | 
| 244 | 
            +
                String getStartUrl()
         | 
| 245 | 
            +
                {
         | 
| 246 | 
            +
                    m_strStartUrl = canonicalizeRhoUrl( RHOCONF().getString("start_path") );
         | 
| 247 | 
            +
                    return m_strStartUrl;
         | 
| 248 | 
            +
                }
         | 
| 249 | 
            +
                
         | 
| 250 | 
            +
                void navigateToUrl(String url)throws Exception
         | 
| 251 | 
            +
                {
         | 
| 252 | 
            +
                	IRhoRubyHelper helper = RhoClassFactory.createRhoRubyHelper();
         | 
| 253 | 
            +
                	helper.navigateUrl(url);
         | 
| 254 | 
            +
                }
         | 
| 255 | 
            +
                
         | 
| 256 | 
            +
                public void loadUrl(String url)throws Exception
         | 
| 257 | 
            +
                {
         | 
| 258 | 
            +
                    boolean callback = false;
         | 
| 259 | 
            +
                    if (url.startsWith("callback:") )
         | 
| 260 | 
            +
                    {
         | 
| 261 | 
            +
                        callback = true;
         | 
| 262 | 
            +
                        url = url.substring(9);
         | 
| 263 | 
            +
                    }
         | 
| 264 | 
            +
                    url = canonicalizeRhoUrl(url);
         | 
| 265 | 
            +
                    if (callback)
         | 
| 266 | 
            +
                    {
         | 
| 267 | 
            +
                        getNet().pushData( url,  "rho_callback=1", null );
         | 
| 268 | 
            +
                    }
         | 
| 269 | 
            +
                    else
         | 
| 270 | 
            +
                        navigateToUrl(url);
         | 
| 271 | 
            +
                }
         | 
| 272 | 
            +
                
         | 
| 273 | 
            +
                public void setAppBackUrl(String url)
         | 
| 274 | 
            +
                {
         | 
| 275 | 
            +
                    if ( url != null && url.length() > 0 )
         | 
| 276 | 
            +
                    {
         | 
| 277 | 
            +
                        m_strAppBackUrlOrig = url;
         | 
| 278 | 
            +
                        m_strAppBackUrl = canonicalizeRhoUrl(url);
         | 
| 279 | 
            +
                    }
         | 
| 280 | 
            +
                    else
         | 
| 281 | 
            +
                    {
         | 
| 282 | 
            +
                        m_strAppBackUrlOrig = "";
         | 
| 283 | 
            +
                        m_strAppBackUrl = "";
         | 
| 284 | 
            +
                    }
         | 
| 285 | 
            +
                }
         | 
| 286 | 
            +
                
         | 
| 287 | 
            +
                public boolean isCloseBack()
         | 
| 288 | 
            +
                {
         | 
| 289 | 
            +
                	return m_strAppBackUrlOrig.equalsIgnoreCase("close");
         | 
| 290 | 
            +
                }
         | 
| 291 | 
            +
                
         | 
| 292 | 
            +
                public void navigateBack()
         | 
| 293 | 
            +
                {
         | 
| 294 | 
            +
                	try{
         | 
| 295 | 
            +
            	        if ( m_strAppBackUrlOrig.length() > 0 )
         | 
| 296 | 
            +
            	            loadUrl(m_strAppBackUrlOrig);
         | 
| 297 | 
            +
            	        else if ( !getCurrentUrl(0).equalsIgnoreCase(getStartUrl()) )
         | 
| 298 | 
            +
            	        {
         | 
| 299 | 
            +
            	        	IRhoRubyHelper helper = RhoClassFactory.createRhoRubyHelper();
         | 
| 300 | 
            +
            	        	helper.navigateBack();
         | 
| 301 | 
            +
            	        }
         | 
| 302 | 
            +
                	}catch(Exception exc)
         | 
| 303 | 
            +
                	{
         | 
| 304 | 
            +
                		LOG.ERROR("Navigate back failed.", exc);
         | 
| 305 | 
            +
                	}
         | 
| 306 | 
            +
                }
         | 
| 307 | 
            +
                
         | 
| 240 308 | 
             
            }
         | 
| @@ -0,0 +1,143 @@ | |
| 1 | 
            +
            package com.rho;
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            import j2me.util.LinkedList;
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            public abstract class ThreadQueue extends RhoThread
         | 
| 6 | 
            +
            {
         | 
| 7 | 
            +
            	private static final RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() : 
         | 
| 8 | 
            +
            		new RhoLogger("ThreadQueue");
         | 
| 9 | 
            +
            	
         | 
| 10 | 
            +
            	public static void setLogCategory(String category)
         | 
| 11 | 
            +
            	{
         | 
| 12 | 
            +
            		LOG.setLogCategory(category);
         | 
| 13 | 
            +
            	}
         | 
| 14 | 
            +
            	
         | 
| 15 | 
            +
            	public static final int QUEUE_POLL_INTERVAL_SECONDS  = 300;
         | 
| 16 | 
            +
            	public static final int QUEUE_POLL_INTERVAL_INFINITE  = Integer.MAX_VALUE/1000;
         | 
| 17 | 
            +
            	public static final int QUEUE_STARTUP_INTERVAL_SECONDS  = 10;
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                public interface IQueueCommand
         | 
| 20 | 
            +
                {
         | 
| 21 | 
            +
                    public abstract boolean equals(IQueueCommand cmd);
         | 
| 22 | 
            +
                    public abstract String toString();
         | 
| 23 | 
            +
                };
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                RhoClassFactory m_ptrFactory;
         | 
| 26 | 
            +
            	int           m_nPollInterval;
         | 
| 27 | 
            +
               	Mutex m_mxStackCommands = new Mutex();
         | 
| 28 | 
            +
               	LinkedList	  m_stackCommands = new LinkedList();
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                boolean m_bNoThreaded;
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                int  getPollInterval(){ return m_nPollInterval;}
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                boolean isNoThreadedMode(){ return m_bNoThreaded; }
         | 
| 35 | 
            +
                void setNonThreadedMode(boolean b){m_bNoThreaded = b;}
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                public RhoClassFactory getFactory(){ return m_ptrFactory; }
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                int getLastPollInterval(){ return 0;}
         | 
| 40 | 
            +
                public abstract void processCommand(IQueueCommand pCmd);
         | 
| 41 | 
            +
                boolean isSkipDuplicateCmd() { return false; }
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                public ThreadQueue(RhoClassFactory factory)
         | 
| 44 | 
            +
                {
         | 
| 45 | 
            +
                    super(factory);
         | 
| 46 | 
            +
                    
         | 
| 47 | 
            +
                    m_nPollInterval = QUEUE_POLL_INTERVAL_SECONDS;
         | 
| 48 | 
            +
                    m_bNoThreaded = false;
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    m_ptrFactory = factory;
         | 
| 51 | 
            +
                }
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                public void addQueueCommand(IQueueCommand pCmd)
         | 
| 54 | 
            +
                { 
         | 
| 55 | 
            +
                    LOG.INFO("addCommand: " + pCmd.toString() );
         | 
| 56 | 
            +
                	synchronized(m_mxStackCommands)
         | 
| 57 | 
            +
                	{
         | 
| 58 | 
            +
            		    boolean bExist = false;
         | 
| 59 | 
            +
                        if ( isSkipDuplicateCmd() )
         | 
| 60 | 
            +
                        {
         | 
| 61 | 
            +
            		        for ( int i = 0; i < (int)m_stackCommands.size(); i++ )
         | 
| 62 | 
            +
            		        {
         | 
| 63 | 
            +
            		        	if ( m_stackCommands.get(i).equals(pCmd) )
         | 
| 64 | 
            +
            		        	{
         | 
| 65 | 
            +
            				        bExist = true;
         | 
| 66 | 
            +
            				        break;
         | 
| 67 | 
            +
            			        }
         | 
| 68 | 
            +
            		        }
         | 
| 69 | 
            +
                        }
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            		    if ( !bExist )
         | 
| 72 | 
            +
                		    m_stackCommands.add(pCmd);
         | 
| 73 | 
            +
            	    }
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                    if ( isNoThreadedMode()  )
         | 
| 76 | 
            +
                        processCommands();
         | 
| 77 | 
            +
                    else
         | 
| 78 | 
            +
            	        stopWait(); 
         | 
| 79 | 
            +
                }
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                public void run()
         | 
| 82 | 
            +
                {
         | 
| 83 | 
            +
            	    LOG.INFO("Starting main routine...");
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            	    int nLastPollInterval = getLastPollInterval();
         | 
| 86 | 
            +
            	    while( !isStopping() )
         | 
| 87 | 
            +
            	    {
         | 
| 88 | 
            +
                        int nWait = m_nPollInterval > 0 ? m_nPollInterval : QUEUE_POLL_INTERVAL_INFINITE;
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                        if ( m_nPollInterval > 0 && nLastPollInterval > 0 )
         | 
| 91 | 
            +
                        {
         | 
| 92 | 
            +
                            int nWait2 = m_nPollInterval - nLastPollInterval;
         | 
| 93 | 
            +
                            if ( nWait2 <= 0 )
         | 
| 94 | 
            +
                                nWait = QUEUE_STARTUP_INTERVAL_SECONDS;
         | 
| 95 | 
            +
                            else
         | 
| 96 | 
            +
                                nWait = nWait2;
         | 
| 97 | 
            +
                        }
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                        if ( nWait >= 0 && !isStopping() && isNoCommands() )
         | 
| 100 | 
            +
            		    {
         | 
| 101 | 
            +
                            LOG.INFO("ThreadQueue blocked for " + nWait + " seconds...");
         | 
| 102 | 
            +
                            wait(nWait);
         | 
| 103 | 
            +
                        }
         | 
| 104 | 
            +
                        nLastPollInterval = 0;
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                        if ( !isStopping() )
         | 
| 107 | 
            +
                		    processCommands();
         | 
| 108 | 
            +
            	    }
         | 
| 109 | 
            +
            	    
         | 
| 110 | 
            +
            	    LOG.INFO("Thread shutdown");	    
         | 
| 111 | 
            +
                }
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                boolean isNoCommands()
         | 
| 114 | 
            +
                {
         | 
| 115 | 
            +
            	    boolean bEmpty = false;
         | 
| 116 | 
            +
            	    synchronized(m_mxStackCommands)
         | 
| 117 | 
            +
                    {		
         | 
| 118 | 
            +
            		    bEmpty = m_stackCommands.isEmpty();
         | 
| 119 | 
            +
            	    }
         | 
| 120 | 
            +
             | 
| 121 | 
            +
            	    return bEmpty;
         | 
| 122 | 
            +
                }
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                void processCommands()//throws Exception
         | 
| 125 | 
            +
                {
         | 
| 126 | 
            +
            	    while(!isStopping() && !isNoCommands())
         | 
| 127 | 
            +
            	    {
         | 
| 128 | 
            +
            		    IQueueCommand pCmd = null;
         | 
| 129 | 
            +
            		    synchronized(m_mxStackCommands)
         | 
| 130 | 
            +
            		    {
         | 
| 131 | 
            +
                		    pCmd = (IQueueCommand)m_stackCommands.removeFirst();
         | 
| 132 | 
            +
                	    }
         | 
| 133 | 
            +
                		
         | 
| 134 | 
            +
            		    processCommand(pCmd);
         | 
| 135 | 
            +
            	    }
         | 
| 136 | 
            +
                }
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                public void setPollInterval(int nInterval)
         | 
| 139 | 
            +
                { 
         | 
| 140 | 
            +
                    m_nPollInterval = nInterval; 
         | 
| 141 | 
            +
                    stopWait();
         | 
| 142 | 
            +
                }
         | 
| 143 | 
            +
            }
         | 
| @@ -55,23 +55,34 @@ public class ClientRegister extends RhoThread | |
| 55 55 | 
             
            		m_NetRequest = RhoClassFactory.createNetRequest();
         | 
| 56 56 | 
             
            		m_nPollInterval = POLL_INTERVAL_SECONDS;
         | 
| 57 57 |  | 
| 58 | 
            -
            		 | 
| 59 | 
            -
            			start(epLow);	
         | 
| 58 | 
            +
            		startUp();
         | 
| 60 59 | 
             
            	}
         | 
| 61 60 |  | 
| 62 61 | 
             
            	public static ClientRegister getInstance(){ return m_pInstance; }
         | 
| 63 62 |  | 
| 63 | 
            +
            	public void startUp() 
         | 
| 64 | 
            +
            	{	
         | 
| 65 | 
            +
            		if ( RhoConf.getInstance().getString("syncserver").length() > 0 )
         | 
| 66 | 
            +
            		{
         | 
| 67 | 
            +
            			start(epLow);	
         | 
| 68 | 
            +
            	        stopWait();
         | 
| 69 | 
            +
            	    }
         | 
| 70 | 
            +
            	}
         | 
| 71 | 
            +
            	
         | 
| 64 72 | 
             
                public void run() 
         | 
| 65 73 | 
             
                {
         | 
| 66 74 | 
             
                	LOG.INFO("ClientRegister start");    	
         | 
| 67 | 
            -
                	while(! | 
| 75 | 
            +
                	while(!isStopping()) 
         | 
| 68 76 | 
             
                	{
         | 
| 69 77 | 
             
                		try
         | 
| 70 78 | 
             
                		{
         | 
| 71 79 | 
             
                			if ( SyncThread.getInstance() != null )
         | 
| 72 80 | 
             
                			{
         | 
| 73 81 | 
             
            	    			if ( doRegister(SyncThread.getSyncEngine()) )
         | 
| 74 | 
            -
             | 
| 82 | 
            +
            	    			{
         | 
| 83 | 
            +
            	    				m_nPollInterval = POLL_INTERVAL_INFINITE;
         | 
| 84 | 
            +
            	    				//break;
         | 
| 85 | 
            +
            	    			}
         | 
| 75 86 | 
             
                			}
         | 
| 76 87 |  | 
| 77 88 | 
             
                		}catch(Exception exc)
         | 
| @@ -83,7 +94,6 @@ public class ClientRegister extends RhoThread | |
| 83 94 | 
             
            			wait(m_nPollInterval);
         | 
| 84 95 | 
             
            		}
         | 
| 85 96 | 
             
                    LOG.INFO( "ClientRegister thread shutdown" );
         | 
| 86 | 
            -
                	
         | 
| 87 97 | 
             
                }
         | 
| 88 98 |  | 
| 89 99 | 
             
                public String getRegisterBody(String strClientID)throws Exception
         | 
| @@ -79,6 +79,7 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 79 79 | 
             
                int m_nSyncPageSize = 2000;
         | 
| 80 80 | 
             
                boolean m_bNoThreaded = false;
         | 
| 81 81 | 
             
                int m_nErrCode = RhoRuby.ERR_NONE;
         | 
| 82 | 
            +
                String m_strError = "";
         | 
| 82 83 |  | 
| 83 84 | 
             
                void setState(int eState){ m_syncState = eState; }
         | 
| 84 85 | 
             
                int getState(){ return m_syncState; }
         | 
| @@ -123,11 +124,12 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 123 124 | 
             
            		m_NetRequest = RhoClassFactory.createNetRequest();
         | 
| 124 125 | 
             
                }
         | 
| 125 126 |  | 
| 126 | 
            -
                void prepareSync(int eState)throws Exception
         | 
| 127 | 
            +
                void prepareSync(int eState, SourceID oSrcID)throws Exception
         | 
| 127 128 | 
             
                {
         | 
| 128 129 | 
             
                    setState(eState);
         | 
| 129 130 | 
             
                    m_bStopByUser = false;
         | 
| 130 131 | 
             
                    m_nErrCode = RhoRuby.ERR_NONE;
         | 
| 132 | 
            +
                    m_strError = "";
         | 
| 131 133 |  | 
| 132 134 | 
             
                    loadAllSources();
         | 
| 133 135 |  | 
| @@ -145,15 +147,20 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 145 147 | 
             
                    }else
         | 
| 146 148 | 
             
                        m_nErrCode = RhoRuby.ERR_CLIENTISNOTLOGGEDIN;
         | 
| 147 149 |  | 
| 148 | 
            -
             | 
| 149 | 
            -
                     | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 150 | 
            +
                    SyncSource src = null;
         | 
| 151 | 
            +
                    if ( oSrcID != null )
         | 
| 152 | 
            +
                    	src = findSource(oSrcID);
         | 
| 153 | 
            +
                    
         | 
| 154 | 
            +
                	if ( src != null )
         | 
| 155 | 
            +
                	{
         | 
| 156 | 
            +
                        src.m_nErrCode = m_nErrCode;
         | 
| 157 | 
            +
                        src.m_strError = m_strError;
         | 
| 158 | 
            +
                        getNotify().fireSyncNotification(src, true, src.m_nErrCode, "");
         | 
| 154 159 | 
             
                    }else
         | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 160 | 
            +
                    {
         | 
| 161 | 
            +
                        getNotify().fireAllSyncNotifications(true, m_nErrCode, m_strError, m_sources, getStartSource());
         | 
| 162 | 
            +
                    }
         | 
| 163 | 
            +
                    
         | 
| 157 164 | 
             
                    stopSync();
         | 
| 158 165 | 
             
                }
         | 
| 159 166 |  | 
| @@ -161,7 +168,7 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 161 168 | 
             
                {
         | 
| 162 169 | 
             
            	    try
         | 
| 163 170 | 
             
            	    {
         | 
| 164 | 
            -
            	        prepareSync(esSyncAllSources);
         | 
| 171 | 
            +
            	        prepareSync(esSyncAllSources, null);
         | 
| 165 172 |  | 
| 166 173 | 
             
            	        if ( isContinueSync() )
         | 
| 167 174 | 
             
            	        {
         | 
| @@ -198,7 +205,7 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 198 205 | 
             
                {
         | 
| 199 206 | 
             
            	    try
         | 
| 200 207 | 
             
            	    {
         | 
| 201 | 
            -
            		    prepareSync(esSearch);
         | 
| 208 | 
            +
            		    prepareSync(esSearch, null);
         | 
| 202 209 | 
             
            		    if ( !isContinueSync() )
         | 
| 203 210 | 
             
            		    {
         | 
| 204 211 | 
             
            		        if ( getState() != esExit )
         | 
| @@ -219,7 +226,6 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 219 226 | 
             
            		        }
         | 
| 220 227 | 
             
            		    }
         | 
| 221 228 |  | 
| 222 | 
            -
            		    int nErrCode = 0;
         | 
| 223 229 | 
             
            		    while( isContinueSync() )
         | 
| 224 230 | 
             
            		    {
         | 
| 225 231 | 
             
            		        int nSearchCount = 0;
         | 
| @@ -247,7 +253,8 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 247 253 | 
             
            		        if ( !resp.isOK() )
         | 
| 248 254 | 
             
            		        {
         | 
| 249 255 | 
             
            		            stopSync();
         | 
| 250 | 
            -
            		             | 
| 256 | 
            +
            		            m_nErrCode = RhoRuby.getErrorFromResponse(resp);
         | 
| 257 | 
            +
            		            m_strError = resp.getCharData();
         | 
| 251 258 | 
             
            		            continue;
         | 
| 252 259 | 
             
            		        }
         | 
| 253 260 |  | 
| @@ -271,7 +278,8 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 271 278 | 
             
            		                LOG.ERROR( "Sync server send search data with incompatible version. Client version: " + getProtocol().getVersion() +
         | 
| 272 279 | 
             
            		                    "; Server response version: " + nVersion );
         | 
| 273 280 | 
             
            		                stopSync();
         | 
| 274 | 
            -
            		                 | 
| 281 | 
            +
            		                m_nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
         | 
| 282 | 
            +
            		                m_strError = resp.getCharData();
         | 
| 275 283 | 
             
            		                continue;
         | 
| 276 284 | 
             
            		            }
         | 
| 277 285 |  | 
| @@ -279,7 +287,8 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 279 287 | 
             
            		            {
         | 
| 280 288 | 
             
            		                LOG.ERROR( "Sync server send search data without source name." );
         | 
| 281 289 | 
             
            		                stopSync();
         | 
| 282 | 
            -
            		                 | 
| 290 | 
            +
            		                m_nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
         | 
| 291 | 
            +
            		                m_strError = resp.getCharData();
         | 
| 283 292 | 
             
            		                continue;
         | 
| 284 293 | 
             
            		            }
         | 
| 285 294 |  | 
| @@ -289,12 +298,12 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 289 298 | 
             
            		            {
         | 
| 290 299 | 
             
            		                LOG.ERROR("Sync server send search data for unknown source name:" + strSrcName);
         | 
| 291 300 | 
             
            		                stopSync();
         | 
| 292 | 
            -
            		                 | 
| 301 | 
            +
            		                m_nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
         | 
| 302 | 
            +
            		                m_strError = resp.getCharData();
         | 
| 293 303 | 
             
            		                continue;
         | 
| 294 304 | 
             
            		            }
         | 
| 295 305 |  | 
| 296 306 | 
             
            		            oSrcArr.reset(0);
         | 
| 297 | 
            -
            		            pSrc.m_bIsSearch = true;
         | 
| 298 307 | 
             
            		            pSrc.setProgressStep(nProgressStep);
         | 
| 299 308 | 
             
            		            pSrc.processServerResponse_ver3(oSrcArr);
         | 
| 300 309 |  | 
| @@ -305,20 +314,7 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 305 314 | 
             
            		            break;
         | 
| 306 315 | 
             
            		    }  
         | 
| 307 316 |  | 
| 308 | 
            -
            		     | 
| 309 | 
            -
            		    {
         | 
| 310 | 
            -
            		        SyncSource src = (SyncSource)m_sources.elementAt(getStartSource());
         | 
| 311 | 
            -
            		        src.m_bIsSearch = true;
         | 
| 312 | 
            -
            		
         | 
| 313 | 
            -
            		    	getNotify().fireSyncNotification(src, true, RhoRuby.ERR_NONE, RhoRuby.getMessageText("sync_completed"));
         | 
| 314 | 
            -
            		    }
         | 
| 315 | 
            -
            		    else if ( nErrCode != 0 )
         | 
| 316 | 
            -
            		    {
         | 
| 317 | 
            -
            		        SyncSource src = (SyncSource)m_sources.elementAt(getStartSource());
         | 
| 318 | 
            -
            		        src.m_nErrCode = nErrCode;
         | 
| 319 | 
            -
            		        src.m_bIsSearch = true;
         | 
| 320 | 
            -
            		        getNotify().fireSyncNotification(src, true, src.m_nErrCode, "");
         | 
| 321 | 
            -
            		    }
         | 
| 317 | 
            +
            		    getNotify().fireAllSyncNotifications(true, m_nErrCode, m_strError, m_sources, getStartSource());
         | 
| 322 318 |  | 
| 323 319 | 
             
            		    //update db info
         | 
| 324 320 | 
             
            		    TimeInterval endTime = TimeInterval.getCurrentTime();
         | 
| @@ -358,7 +354,7 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 358 354 |  | 
| 359 355 | 
             
            	    try
         | 
| 360 356 | 
             
            	    {
         | 
| 361 | 
            -
            	        prepareSync(esSyncSource);
         | 
| 357 | 
            +
            	        prepareSync(esSyncSource, oSrcID);
         | 
| 362 358 |  | 
| 363 359 | 
             
            	        if ( isContinueSync() )
         | 
| 364 360 | 
             
            	        {
         | 
| @@ -473,6 +469,10 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 473 469 | 
             
            	            	getUserDB().executeSQL("UPDATE client_info SET client_id=?", clientID);
         | 
| 474 470 | 
             
            	            else
         | 
| 475 471 | 
             
            	            	getUserDB().executeSQL("INSERT INTO client_info (client_id) values (?)", clientID);
         | 
| 472 | 
            +
            	            
         | 
| 473 | 
            +
            		    	if ( ClientRegister.getInstance() != null )
         | 
| 474 | 
            +
            		    		ClientRegister.getInstance().startUp();	    	
         | 
| 475 | 
            +
            	            
         | 
| 476 476 | 
             
            		    }else if ( bResetClient )
         | 
| 477 477 | 
             
            		    {
         | 
| 478 478 | 
             
            		    	if ( !resetClientIDByNet(clientID) )
         | 
| @@ -512,7 +512,10 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 512 512 | 
             
            */	    				
         | 
| 513 513 |  | 
| 514 514 | 
             
            	    if ( !resp.isOK() )
         | 
| 515 | 
            +
            	    {
         | 
| 515 516 | 
             
            	    	m_nErrCode = RhoRuby.getErrorFromResponse(resp);
         | 
| 517 | 
            +
            	    	m_strError = resp.getCharData();
         | 
| 518 | 
            +
            	    }
         | 
| 516 519 | 
             
            	    /*else
         | 
| 517 520 | 
             
                	{
         | 
| 518 521 | 
             
                		processServerSources(resp.getCharData());
         | 
| @@ -545,7 +548,10 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 545 548 | 
             
            	    {
         | 
| 546 549 | 
             
            	    	m_nErrCode = RhoRuby.getErrorFromResponse(resp);
         | 
| 547 550 | 
             
            	    	if ( m_nErrCode == RhoRuby.ERR_NONE )
         | 
| 551 | 
            +
            	    	{
         | 
| 548 552 | 
             
            	    		m_nErrCode = RhoRuby.ERR_UNEXPECTEDSERVERRESPONSE;
         | 
| 553 | 
            +
            	    		m_strError = resp.getCharData();
         | 
| 554 | 
            +
            	    	}
         | 
| 549 555 | 
             
            	    }
         | 
| 550 556 |  | 
| 551 557 | 
             
            	    return "";
         | 
| @@ -778,11 +784,11 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 778 784 | 
             
            		    else
         | 
| 779 785 | 
             
            		    	getUserDB().executeSQL("INSERT INTO client_info (session) values (?)", strSession);
         | 
| 780 786 |  | 
| 781 | 
            -
            		    if ( ClientRegister.getInstance() != null )
         | 
| 782 | 
            -
            		    	ClientRegister.getInstance().stopWait();
         | 
| 783 | 
            -
            		    
         | 
| 784 787 | 
             
            	    	getNotify().callLoginCallback(callback, RhoRuby.ERR_NONE, "" );
         | 
| 785 788 |  | 
| 789 | 
            +
            	    	if ( ClientRegister.getInstance() != null )
         | 
| 790 | 
            +
            	    		ClientRegister.getInstance().startUp();	    	
         | 
| 791 | 
            +
            	    	
         | 
| 786 792 | 
             
            		}catch(Exception exc)
         | 
| 787 793 | 
             
            		{
         | 
| 788 794 | 
             
            			LOG.ERROR("Login failed.", exc);
         | 
| @@ -817,7 +823,7 @@ public class SyncEngine implements NetRequest.IRhoSession | |
| 817 823 | 
             
            		getUserDB().executeSQL( "UPDATE client_info SET session = NULL");
         | 
| 818 824 | 
             
            	    m_strSession = "";
         | 
| 819 825 |  | 
| 820 | 
            -
            	    loadAllSources();
         | 
| 826 | 
            +
            	    //loadAllSources();
         | 
| 821 827 | 
             
            	}
         | 
| 822 828 |  | 
| 823 829 | 
             
            	public void setSyncServer(String url)throws Exception
         |