/** If an attribute for this record is updated or deleted this method shall be called. It will update the state attribute, which may be used by remote devices to aid caching. @internalTechnology @released */ EXPORT_C void CSdpServRecord::RecordStateChange() { TDblQueIter<CSdpAttr> attrIter(iAttributes); CSdpAttr* attr = attrIter++; while(attr) { if(attr->AttributeID() == KSdpAttrIdServiceRecordState) { TUint state = iRecordState->Uint(); TPckg<TUint> stateBuf(0); SdpUtil::PutUint(&stateBuf[0], ++state, sizeof(TUint)); iRecordState->SetUintValue(stateBuf); // This encodes iRecordState into the buffer provided at construction iEncodeBuf.SetLength(0); TRAPD(err, iEncoderVisitor->EncodeAttributeL(*iRecordState)); // Attribute encoding can only fail if the attribute is of an unknown type // or the supplied buffer is too small. We have set the length of the // buffer to the correct length on creation so that will not fail. // We know iRecordState is a CSdpAttrValueUint so cannot fail. __ASSERT_ALWAYS(!err, DbPanic(ESdpDbAttributeEncodingFailed)); __ASSERT_ALWAYS(attr->Value().Type() == ETypeEncoded, DbPanic(ESdpDbStoredAttrValNotEncoded)); reinterpret_cast<CSdpAttrValueEncoded&>(attr->Value()).SetEncodedValue(iEncodeBuf); break; } attr = attrIter++; } }
void CSdpAttrIdMatchList::FindAttributesL(CSdpServRecord &aRec, MAttributeMatchHandler &aHandler) const { for(TServAttrIter attrIter(aRec.AttributeIter()); attrIter; attrIter++) {// Iterate thru attributes in record if (InMatchList((*attrIter).AttributeID())) {// this attribute is is the list -- signal it aHandler.AttributeInMatchListL(*attrIter); } } }
void CSyncSource::processSyncCommand(const String& strCmd, CJSONEntry oCmdEntry) { CJSONStructIterator objIter(oCmdEntry); for( ; !objIter.isEnd() && getSync().isContinueSync(); objIter.next() ) { String strObject = objIter.getCurKey(); CJSONStructIterator attrIter( objIter.getCurValue() ); if ( m_bSchemaSource ) processServerCmd_Ver3_Schema(strCmd,strObject,attrIter); else { for( ; !attrIter.isEnd() && getSync().isContinueSync(); attrIter.next() ) { String strAttrib = attrIter.getCurKey(); String strValue = attrIter.getCurString(); processServerCmd_Ver3(strCmd,strObject,strAttrib,strValue); } } if ( getSyncType().compare("none") == 0 ) continue; int nSyncObjectCount = getNotify().incLastSyncObjectCount(getID()); if ( getProgressStep() > 0 && (nSyncObjectCount%getProgressStep() == 0) ) getNotify().fireSyncNotification(this, false, RhoAppAdapter.ERR_NONE, ""); if ( getDB().isUIWaitDB() ) { LOG(INFO) + "Commit transaction because of UI request."; getDB().endTransaction(); CSyncThread::getInstance()->sleep(1000); getDB().startTransaction(); } } }
/* Search through all attributes in a record either to find if it matches the UUIDlist, or if the attributes match the AttrIdMatchList or both. If there is no UUIDList then the sizes of matched attributes is saved to the size collector */ void CResponseSizeVisitor::SearchRecordL(CSdpServRecord& aRec) { // could be in calling routine if (iSearchPattern) { if (iFoundIndex) { delete iFoundIndex; iFoundIndex = 0; } iFoundIndex = CBitMapAllocator::NewL(iSearchSize); iUseThis = EFalse; } else iUseThis = ETrue; // if (iCurrentRec) delete iCurrentRec; // I want a reset. iCurrentRec = CHandleItem::CHandleItemL(aRec.Handle(), &aRec); for(TServAttrIter attrIter(aRec.AttributeIter()); attrIter; attrIter++) { /* we are checking every attribute, searching for the UUIDs. We don't exit if we find them all because we also want to get the sizes of any attributes which match our list if we have one. The array of sizes is built, then thrown away if it doesn't match. */ if (iAtMatList) { TSdpAttributeID theAttrID = (*attrIter).AttributeID(); if(iAtMatList->InMatchList(theAttrID)) {// create a new array entry TUint size = (*attrIter).Value().DataSize(); TSdpElementType type = (*attrIter).Value().Type(); if (type != ETypeEncoded) { // some server records may be un-encoded size += TElementEncoder::HeaderSize(type, size); // add the header size } if(!(type==ETypeNil)&&!(type==ETypeEncoded&&size<=1)) { // only include attribute if not either null or encoded null ... // (size of encoded (which INCLUDES header) in all non-null cases is > 1 // because other attribute types either have // to have a header plus at least one byte, or they have at least a two byte header.) iCurrentRec->AddAttrItemL(theAttrID, size, attrIter); } } } // check if any UUIDs match only if we have a UUIDList. if (iSearchPattern) (*attrIter).AcceptVisitorL(*this); } if (iUseThis) { // now we have to copy the array(s) we've built up. iCollector->AddHandleL(iCurrentRec); iCurrentRec = 0; } else { delete iCurrentRec; // I don't want a heap fault. iCurrentRec = 0; } }