// ----------------------------------------------------------------------------- void CPresenceCacheBuddyInfo::SetAnyFieldPtrL( HBufC16* aKey, HBufC8* aValue ) { if ( !aKey ) { User::Leave( KErrArgument ); } // Remove old values first RemoveField( aKey->Des() ); TInt insertPos = iIds.Find(0); if ( insertPos < 0 ) { insertPos = iIds.Count(); iIds.Append( aKey ); iValues.Append( aValue ); } else { iIds[insertPos] = aKey; iValues[insertPos] = aValue; } iHashMap.InsertL( aKey, insertPos ); }
// ----------------------------------------------------------------------------- void CPresenceCacheBuddyInfo::SetAnyFieldL( const TDesC16& aKey, const TDesC8& aValue ) { if( NPresenceCacheFieldName::KExpiry().CompareF( aKey ) == 0 ) { TPckg<TInt64> expiryPck( iExpiryTime ); expiryPck.Copy( aValue ); // write also to key-value map } // Remove old values first RemoveField( aKey ); HBufC8* valueBuffer = aValue.AllocLC(); HBufC* keyBuffer = aKey.AllocLC(); TInt insertPos = iIds.Find(0); if ( insertPos < 0 ) { insertPos = iIds.Count(); iIds.Append( keyBuffer ); iValues.Append( valueBuffer ); } else { iIds[insertPos] = keyBuffer; iValues[insertPos] = valueBuffer; } iHashMap.InsertL( keyBuffer, insertPos ); CleanupStack::Pop( keyBuffer ); CleanupStack::Pop( valueBuffer ); }
// ----------------------------------------------------------------------------- void CPresenceCacheBuddyInfo::DoSet16BitValueL( const TDesC& aKey, const TDesC& aValue ) { // Remove old values first RemoveField( aKey ); //Convert Unicode to Utf-8 HBufC8* convertBuffer = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aValue ); CleanupStack::PushL( convertBuffer ); HBufC* keyBuffer = aKey.AllocLC(); TInt insertPos = iIds.Find(0); if ( insertPos < 0 ) { insertPos = iIds.Count(); iIds.Append( keyBuffer ); iValues.Append( convertBuffer ); } else { iIds[insertPos] = keyBuffer; iValues[insertPos] = convertBuffer; } iHashMap.InsertL( keyBuffer, insertPos ); CleanupStack::Pop( keyBuffer ); CleanupStack::Pop( convertBuffer ); }
int CAPETag::SetFieldBinary(const str_utf16 * pFieldName, const void * pFieldValue, int nFieldBytes, int nFieldFlags) { if (m_bAnalyzed == FALSE) { Analyze(); } if (pFieldName == NULL) return -1; // check to see if we're trying to remove the field (by setting it to NULL or an empty string) BOOL bRemoving = (pFieldValue == NULL) || (nFieldBytes <= 0); // get the index int nFieldIndex = GetTagFieldIndex(pFieldName); if (nFieldIndex != -1) { // existing field // fail if we're read-only (and not ignoring the read-only flag) if ((m_bIgnoreReadOnly == FALSE) && (m_aryFields[nFieldIndex]->GetIsReadOnly())) return -1; // erase the existing field SAFE_DELETE(m_aryFields[nFieldIndex]) if (bRemoving) { return RemoveField(nFieldIndex); } } else { if (bRemoving)
int CAPETag::SetFieldString(const str_utf16 * pFieldName, const str_utf16 * pFieldValue) { // remove if empty if ((pFieldValue == NULL) || (wcslen(pFieldValue) <= 0)) return RemoveField(pFieldName); // UTF-8 encode the value and call the UTF-8 SetField(...) CSmartPtr<str_utf8> spFieldValueUTF8(GetUTF8FromUTF16((str_utf16 *) pFieldValue), TRUE); return SetFieldString(pFieldName, (const char *) spFieldValueUTF8.GetPtr(), TRUE); }
void FieldHelper::RemoveAllFields( const CString& type ) { AcStringArray fields; GetAllFields( type, fields ); int len = fields.length(); for( int i = 0; i < len; i++ ) { RemoveField( type, fields[i].kACharPtr() ); } RemoveKey_Helper( PROPERTY_DATA_FIELD_DICT, type ); }
int CAPETag::SetFieldString(const str_utf16 * pFieldName, const char * pFieldValue, BOOL bAlreadyUTF8Encoded) { // remove if empty if ((pFieldValue == NULL) || (strlen(pFieldValue) <= 0)) return RemoveField(pFieldName); // get the length and call the binary SetField(...) if (bAlreadyUTF8Encoded == FALSE) { CSmartPtr<char> spUTF8((char *) GetUTF8FromANSI(pFieldValue), TRUE); int nFieldBytes = strlen(spUTF8.GetPtr()); return SetFieldBinary(pFieldName, spUTF8.GetPtr(), nFieldBytes, TAG_FIELD_FLAG_DATA_TYPE_TEXT_UTF8); } else { int nFieldBytes = strlen(pFieldValue); return SetFieldBinary(pFieldName, pFieldValue, nFieldBytes, TAG_FIELD_FLAG_DATA_TYPE_TEXT_UTF8); } }