CJSONStructIterator::CJSONStructIterator(const CJSONEntry& oEntry, const char* strName) { m_struct = 0; m_curEntry = 0; m_rootObject = 0; CJSONEntry oItem = oEntry.getEntry(strName); if ( !oItem.isEmpty() ) { m_struct = json_object_get_object( oItem.getObject() ); m_curEntry = m_struct->head; } }
jobject rho_cast_helper<jobject, CJSONEntry>::operator ()(JNIEnv *env, const CJSONEntry& jsonEntry) { if(jsonEntry.isEmpty() || jsonEntry.isNull()) { return 0; } if (!initConvertor(env)) { return 0; } if(jsonEntry.isString()) { RAWTRACE("Convert to String object"); return rho_cast<jstring>(env, jsonEntry.getString()); } if(jsonEntry.isArray()) { RAWTRACE("Convert to Collection object"); return convertJsonEntryToJavaCollection(jsonEntry); } if(jsonEntry.isObject()) { RAWTRACE("Convert to Map object"); return convertJsonEntryToJavaMap(jsonEntry); } if(jsonEntry.isBoolean()) { RAWTRACE("Convert to Boolean object"); return RhoJniConvertor::getBooleanObject(jsonEntry.getBoolean()); } if(jsonEntry.isInteger()) { RAWTRACE("Convert to Integer object"); return RhoJniConvertor::getIntegerObject(jsonEntry.getInt()); } if(jsonEntry.isFloat()) { RAWTRACE("Convert to Double object"); return RhoJniConvertor::getDoubleObject(jsonEntry.getDouble()); } RAWTRACE("Convert to null"); return 0; }
String CSyncEngine::requestClientIDByNet() { String serverUrl = RHOCONF().getString("syncserver"); String strUrl = serverUrl + "clientcreate"; String strQuery = SYNC_SOURCE_FORMAT(); NetResponse(resp,getNet().pullData(strUrl+strQuery)); if ( resp.isOK() && resp.getCharData() != null ) { const char* szData = resp.getCharData(); CJSONEntry oJsonEntry(szData); CJSONEntry oJsonObject = oJsonEntry.getEntry("client"); if ( !oJsonObject.isEmpty() ) return oJsonObject.getString("client_id"); } return ""; }
boolean CSyncSource::processSyncObject_ver1(CJSONEntry oJsonObject, int nSrcID)//throws Exception { const char* strOldObject = oJsonObject.getString("oo"); if ( isDeleteObjectsPass() != (nSrcID < 0) ) return true; if ( oJsonObject.hasName("e") ) { const char* strError = oJsonObject.getString("e"); getNotify().addCreateObjectError(nSrcID,strOldObject,strError); return true; } const char* strObject = oJsonObject.getString("o"); CJSONArrayIterator oJsonArr(oJsonObject, "av"); //oo conflicts boolean bUpdatedOO = false; // for( ; !oJsonArr.isEnd() && getSync().isContinueSync(); oJsonArr.next() ) { CJSONEntry oJsonEntry = oJsonArr.getCurItem(); if ( oJsonEntry.isEmpty() ) continue; if ( nSrcID >= 0 ) //insert { CValue value(oJsonEntry,1); if ( !downloadBlob(value) ) return false; String strAttrib = oJsonEntry.getString("a"); //oo conflicts if ( strOldObject != null && !bUpdatedOO ) { getDB().executeSQL("UPDATE object_values SET object=? where object=? and source_id=?", strObject, strOldObject, nSrcID ); getDB().executeSQL("UPDATE changed_values SET object=? where object=? and source_id=?", strObject, strOldObject, nSrcID ); getNotify().onObjectChanged(nSrcID,strOldObject, CSyncNotify::enCreate); bUpdatedOO = true; } DBResult(resInsert, getDB().executeSQLReportNonUnique("INSERT INTO object_values \ (id, attrib, source_id, object, value, attrib_type) VALUES(?,?,?,?,?,?)", value.m_nID, strAttrib, nSrcID, strObject, value.m_strValue, value.m_strAttrType ) ); if ( resInsert.isNonUnique() ) { getDB().executeSQL("UPDATE object_values \ SET id=?, value=?, attrib_type=? WHERE object=? and attrib=? and source_id=?", value.m_nID, value.m_strValue, value.m_strAttrType, strObject, strAttrib, nSrcID ); // oo conflicts getDB().executeSQL("UPDATE changed_values SET main_id=? where object=? and attrib=? and source_id=? and sent<=1", value.m_nID, strObject, strAttrib, nSrcID ); getDB().executeSQL("UPDATE changed_values SET sent=4 where object=? and attrib=? and source_id=? and sent>1", strObject, strAttrib, nSrcID ); // } getNotify().onObjectChanged(nSrcID,strObject, CSyncNotify::enUpdate); m_nInserted++; }else