예제 #1
0
 public SyncLoginCommand(String name, String password, String callback, SyncNotify.SyncNotification pNotify) :
     base(scLogin, callback, false)
 {
     m_strName     = name;
     m_strPassword = password;
     m_pNotify     = pNotify;
 }
예제 #2
0
        public void login(String name, String password, SyncNotify.SyncNotification oNotify)
        {
            try {
                /*
                 *                      processServerSources("{\"sources\":{ \"ProductEx\":{ "+
                 *              "\"sync_type\":\"incremental\", \"partition\":\"application\", \"source_id\":\"7\","+
                 *              " \"sync_priority\":\"0\", \"model_type\":\"fixed_schema\", "+
                 *              " \"schema\":{\"version\":\"1.1\", \"property\":{\"brand\":\"string\", \"price\":\"string\", \"quantity\":\"string\", \"name\":\"string\", "+
                 *              " \"image_url\":\"blob\", \"image_url_ex\":\"blob,overwrite\"}, "+
                 *              " \"index\":[{\"by_brand_price1\":\"brand,price\"}, {\"by_quantity1\":\"quantity\"}], \"unique_index\":[{\"by_name1\":\"name\"}]}, "+
                 *              " \"belongs_to\":{\"brand\":\"Customer\"}}}}");//, \"schema_version\":\"1.0\"
                 */
                NetResponse resp = null;
                m_bStopByUser = false;

                try{
                    resp = getNet().pullCookies(getProtocol().getLoginUrl(), getProtocol().getLoginBody(name, password), this);
                    int nErrCode = RhoAppAdapter.getErrorFromResponse(resp);
                    if (nErrCode != RhoAppAdapter.ERR_NONE)
                    {
                        getNotify().callLoginCallback(oNotify, nErrCode, resp.getCharData());
                        return;
                    }
                }catch (Exception exc)
                {
                    LOG.ERROR("Login failed.", exc);
                    getNotify().callLoginCallback(oNotify, RhoAppAdapter.getNetErrorCode(exc), "");
                    return;
                }

                String strSession = resp.getCharData();
                if (strSession == null || strSession.length() == 0)
                {
                    LOG.ERROR("Return empty session.");
                    getNotify().callLoginCallback(oNotify, RhoAppAdapter.ERR_UNEXPECTEDSERVERRESPONSE, "");
                    return;
                }

                if (isStoppedByUser())
                {
                    return;
                }

                IDBResult res = getUserDB().executeSQL("SELECT * FROM client_info");
                if (!res.isEnd())
                {
                    getUserDB().executeSQL("UPDATE client_info SET session=?", strSession);
                }
                else
                {
                    getUserDB().executeSQL("INSERT INTO client_info (session) values (?)", strSession);
                }

                if (RHOCONF().isExist("rho_sync_user"))
                {
                    String strOldUser = RHOCONF().getString("rho_sync_user");
                    if (name.compareTo(strOldUser) != 0)
                    {
                        if (isNoThreadedMode())
                        {
                            RhoRuby.resetDBOnSyncUserChanged();
                        }
                        else
                        {
                            NetResponse resp1 = getNet().pushData(getNet().resolveUrl("/system/resetDBOnSyncUserChanged"), "", null);
                        }
                    }
                }
                RHOCONF().setString("rho_sync_user", name, true);

                getNotify().callLoginCallback(oNotify, RhoAppAdapter.ERR_NONE, "");

                if (ClientRegister.getInstance() != null)
                {
                    getUserDB().executeSQL("UPDATE client_info SET token_sent=?", 0);
                    ClientRegister.getInstance().startUp();
                }
            }catch (Exception exc)
            {
                LOG.ERROR("Login failed.", exc);
                getNotify().callLoginCallback(oNotify, RhoAppAdapter.ERR_RUNTIME, "");
            }
        }
예제 #3
0
파일: SyncThread.cs 프로젝트: artemk/rhodes
 		    public SyncLoginCommand(String name, String password, String callback, SyncNotify.SyncNotification pNotify) :
              base(scLogin,callback,false)
 		    {
 			    m_strName = name;
 			    m_strPassword = password;
 			    m_pNotify = pNotify; 
 		    }