EXPORT_C TInt CContactItemViewDef::Find(const CContentType &aContentType) const /** Searches the view definition for any field type contained in the specified content type. @param aContentType Content type containing the field types to search for. @return The index in the view definition of the first matching field type or KErrNotFound. */ { TInt ret=KErrNotFound; for(TInt loop=0;loop<aContentType.FieldTypeCount();loop++) { ret=Find(aContentType.FieldType(loop)); if (ret!=KErrNotFound) break; } return(ret); }
static CContentType *CclParseContent(lua_State *l) { Assert(lua_istable(l, -1)); CContentType *content = NULL; ConditionPanel *condition = NULL; PixelPos pos(0, 0); for (lua_pushnil(l); lua_next(l, -2); lua_pop(l, 1)) { const char *key = LuaToString(l, -2); if (!strcmp(key, "Pos")) { CclGetPos(l, &pos.x, &pos.y); } else if (!strcmp(key, "More")) { Assert(lua_istable(l, -1)); lua_rawgeti(l, -1, 1); // Method name lua_rawgeti(l, -2, 2); // Method data key = LuaToString(l, -2); if (!strcmp(key, "Text")) { content = new CContentTypeText; } else if (!strcmp(key, "FormattedText")) { content = new CContentTypeFormattedText; } else if (!strcmp(key, "FormattedText2")) { content = new CContentTypeFormattedText2; } else if (!strcmp(key, "Icon")) { content = new CContentTypeIcon; } else if (!strcmp(key, "LifeBar")) { content = new CContentTypeLifeBar; } else if (!strcmp(key, "CompleteBar")) { content = new CContentTypeCompleteBar; } else { LuaError(l, "Invalid drawing method '%s' in DefinePanelContents" _C_ key); } content->Parse(l); lua_pop(l, 2); // Pop Variable Name and Method } else if (!strcmp(key, "Condition")) { condition = ParseConditionPanel(l); } else { LuaError(l, "'%s' invalid for Contents in DefinePanelContents" _C_ key); } } content->Pos = pos; content->Condition = condition; return content; }
// --------------------------------------------------------------------------- // CPIMContactFieldInfo::FieldInternalAttributes // (other items were commented in a header) // --------------------------------------------------------------------------- // void CPIMContactFieldInfo::GetFieldInternalAttributesL( const CContentType& aContentType, CArrayFix<TUid>& aArrayOfAttributes) const { JELOG2(EPim); TInt fieldCount = aContentType.FieldTypeCount(); for (TInt i = 0; i < fieldCount; i++) { TFieldType fieldType = aContentType.FieldType(i); TBool isSupported = EFalse; for (TInt j = 0; j < KPIMFieldAttributeMapSize && !isSupported; j++) { // Generate uid from the specified Contacts Model field id TUid uid = { KPIMFieldAttributeMap[j][1] }; // Add this attribute to internal attributes array if // it is not supported. This covers all unknow attributes // that those won't be lost when a database item is modified if (fieldType == uid) { isSupported = ETrue; } } // Check that if field info array knows this Uid TInt fieldInfoCount = iFieldsInfo->Count(); for (TInt j = 0; j < fieldInfoCount && !isSupported; j++) { const TPIMFieldInfo& fieldInfo = (*iFieldsInfo)[j]; // Contacts Model field type values are defined as field types // So the following mappings is equal to check with the field type TUid uid = { fieldInfo.iContactsModelField }; if (fieldType == uid) { isSupported = ETrue; } } // Not supported, add to internal attributes if (!isSupported) { aArrayOfAttributes.AppendL(fieldType); } } }
/** * Add fields that meet some desired sort order * @param aContact - Contact to be updated woth desired fields * @param aSortOrder - specifies information about the desired fields */ void CTestContactViewCRUDOperationsStep::AddContactFieldL(CContactItem& aContact, const RContactViewSortOrder& aSortOrder) { const TInt KMaxSortOrderCount = 3; for(TInt i = 0; i < KMaxSortOrderCount; ++i) { TFieldType fieldType = aSortOrder[i]; TStorageType storageType = GetStorageType(fieldType); CContentType* contentType = CContentType::NewL(); CleanupStack::PushL(contentType); contentType->AddFieldTypeL(fieldType); CContactItemField* field = CContactItemField::NewL(storageType, *contentType); CleanupStack::PushL(field); SetDataL(fieldType, *field); aContact.AddFieldL(*field); CleanupStack::Pop(field); CleanupStack::PopAndDestroy(contentType); } }
void CTestContactViewCRUDOperationsStep::AddMatchingStringToContactL(CContactItem& aContact) { _LIT(KDesiredMatchingString, "matchingstring"); TPtrC desiredMatchingString; GetStringFromConfig(ConfigSection(), KDesiredMatchingString, desiredMatchingString); _LIT(KDesiredContactField, "contactfield"); TPtrC desiredContactField; GetStringFromConfig(ConfigSection(), KDesiredContactField, desiredContactField); TUid uidInfo = GetContactFieldType(desiredContactField); CContactItemFieldSet& fieldSet = aContact.CardFields(); TInt pos = fieldSet.Find(uidInfo); if(pos == KErrNotFound) { TFieldType fieldType = uidInfo; TStorageType storageType = GetStorageType(fieldType); CContentType* contentType = CContentType::NewL(); CleanupStack::PushL(contentType); contentType->AddFieldTypeL(fieldType); CContactItemField* field = CContactItemField::NewL(storageType, *contentType); CleanupStack::PushL(field); field->TextStorage()->SetTextL(desiredMatchingString); aContact.AddFieldL(*field); CleanupStack::Pop(field); CleanupStack::PopAndDestroy(contentType); } else { CContactItemField& field = fieldSet[pos]; field.TextStorage()->SetTextL(desiredMatchingString); } }
// --------------------------------------------------------------------------- // CPIMContactFieldInfo::FieldAttributes // (other items were commented in a header) // --------------------------------------------------------------------------- // TPIMAttribute CPIMContactFieldInfo::FieldAttributes( const CContentType& aContentType) const { JELOG2(EPim); TPIMAttribute retVal = KPIMAttrNone; for (TInt i = 0; i < KPIMFieldAttributeMapSize; i++) { // Generate uid from the specified Contacts Model field id TUid uid = { KPIMFieldAttributeMap[i][1] }; // Match if this content type contains certain PIM attribute if (aContentType.ContainsFieldType(uid)) { retVal |= KPIMFieldAttributeMap[i][0]; } } return retVal; }
// --------------------------------------------------------------------------- // CPIMContactFieldInfo::StringFieldContentTypeL // (other items were commented in a header) // --------------------------------------------------------------------------- // CContentType* CPIMContactFieldInfo::StringFieldContentTypeL( const TPIMContactField aContactField, const TPIMAttribute aAttributes, EContactFieldCategory& aCategory) const { JELOG2(EPim); CContentType* type = NULL; switch (aContactField) { case EPIMContactEmail: { type = CContentType::NewL(KUidContactFieldEMail, KUidContactFieldVCardMapEMAILINTERNET); CleanupStack::PushL(type); if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } if ((aAttributes & EPIMContactAttrPreferred) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapPREF); } CleanupStack::Pop(type); break; } case EPIMContactNote: { type = CContentType::NewL(KUidContactFieldNote, KUidContactFieldVCardMapNOTE); aCategory = EContactCategoryOther; break; } case EPIMContactOrg: { type = CContentType::NewL(KUidContactFieldCompanyName, KUidContactFieldVCardMapORG); aCategory = EContactCategoryWork; break; } case EPIMContactTel: { // PIM API Contact.TEL field is mapped to either a // telephone or a fax field in Contacts Model according to // PIM API attributes if ((aAttributes & EPIMContactAttrFax) != 0) { type = CContentType::NewL(KUidContactFieldFax, KUidContactFieldVCardMapTEL); } else { type = CContentType::NewL(KUidContactFieldPhoneNumber, KUidContactFieldVCardMapTEL); } CleanupStack::PushL(type); // PIM API attributes are further mapped to details in // Contacts Model fields. // Fax, pager and mobile numbers are preferred in this order // (rarest first). if ((aAttributes & EPIMContactAttrFax) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapFAX); } else if ((aAttributes & EPIMContactAttrPager) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapPAGER); aCategory = EContactCategoryNone; } else if ((aAttributes & EPIMContactAttrMobile) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapCELL); } else if ((aAttributes & EPIMContactAttrAuto) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapCAR); aCategory = EContactCategoryNone; } else if ((aAttributes & EPIMContactAttrAsst) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapAssistantTel); // Assistant Phone is not mapped as a Telephone field in Pbk // so we have to set the mapping to match it type->SetMapping(KUidContactFieldVCardMapAssistantTel); } else if ((aAttributes & EPIMContactAttrExtVideoCall) != 0) { type ->AddFieldTypeL(KUidContactFieldVCardMapVIDEO); } else if ((aAttributes & EPIMContactAttrOther) != 0) { // Discard ATTR_OTHER because contacts model doesn't // provide anything where we could map this attribute } else { type->AddFieldTypeL(KUidContactFieldVCardMapVOICE); } if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } if ((aAttributes & EPIMContactAttrPreferred) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapPREF); } if ((aAttributes & EPIMContactAttrSms) != 0) { TUid uid = { KPIMIntPbkDefaultFieldSms }; type->AddFieldTypeL(uid); } CleanupStack::Pop(type); break; } case EPIMContactTitle: { type = CContentType::NewL(KUidContactFieldJobTitle, KUidContactFieldVCardMapTITLE); aCategory = EContactCategoryWork; break; } case EPIMContactNickname: { type = CContentType::NewL(KUidContactFieldSecondName, KUidContactFieldVCardMapSECONDNAME); break; } case EPIMContactUrl: { type = CContentType::NewL(KUidContactFieldUrl, KUidContactFieldVCardMapURL); CleanupStack::PushL(type); if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } CleanupStack::Pop(type); break; } case EPIMContactExtSip: { type = CContentType::NewL(KUidContactFieldSIPID, KUidContactFieldVCardMapSIPID); CleanupStack::PushL(type); // Phonebook needs this field to separate SIP field from VOIP field type->AddFieldTypeL(KUidContactFieldVCardMapSIPID); CleanupStack::Pop(type); break; } case EPIMContactExtDtmf: { // Note: DTMF is not imported or exported in vCards type = CContentType::NewL(KUidContactFieldDTMF, KUidContactFieldVCardMapUnknown); break; } case EPIMContactExtWvUserId: { type = CContentType::NewL(KUidContactFieldIMAddress, KUidContactFieldVCardMapWV); break; } case EPIMContactExtDepartment: { type = CContentType::NewL(KUidContactFieldDepartmentName, KUidContactFieldVCardMapDepartment); break; } case EPIMContactExtAssistantName: { type = CContentType::NewL(KUidContactFieldAssistant, KUidContactFieldVCardMapAssistant); break; } case EPIMContactExtChildren: { type = CContentType::NewL(KUidContactFieldChildren, KUidContactFieldVCardMapChildren); break; } case EPIMContactExtSpouse: { type = CContentType::NewL(KUidContactFieldSpouse, KUidContactFieldVCardMapSpouse); break; } case EPIMContactExtVoip: { type = CContentType::NewL(KUidContactFieldSIPID, KUidContactFieldVCardMapVOIP); CleanupStack::PushL(type); if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } if ((aAttributes & EPIMContactAttrPreferred) != 0) { TUid uid = { KPIMIntPbkDefaultFieldVoip }; type->AddFieldTypeL(uid); } CleanupStack::Pop(type); break; } case EPIMContactExtPTT: { type = CContentType::NewL(KUidContactFieldSIPID, KUidContactFieldVCardMapPOC); CleanupStack::PushL(type); // Phonebook needs this field to separate SIP field from PTT field type->AddFieldTypeL(KUidContactFieldVCardMapPOC); CleanupStack::Pop(type); break; } case EPIMContactExtSWIS: { type = CContentType::NewL(KUidContactFieldSIPID, KUidContactFieldVCardMapSWIS); CleanupStack::PushL(type); // Phonebook needs this field to separate SIP field from SWIS field type->AddFieldTypeL(KUidContactFieldVCardMapSWIS); CleanupStack::Pop(type); break; } default: { __ASSERT_DEBUG(EFalse, User::Panic(KPIMPanicCategory, EPIMPanicUnsupportedField)); } } return type; }
// --------------------------------------------------------------------------- // CPIMContactFieldInfo::AddressContentTypeL // (other items were commented in a header) // --------------------------------------------------------------------------- // CContentType* CPIMContactFieldInfo::AddressContentTypeL( TPIMContactAddrElement aElement, EContactFieldCategory aCategory) const { JELOG2(EPim); CContentType* type = NULL; switch (aElement) { case EPIMContactAddrPoBox: { type = CContentType::NewL(KUidContactFieldPostOffice, KUidContactFieldVCardMapPOSTOFFICE); break; } case EPIMContactAddrExtra: { type = CContentType::NewL(KUidContactFieldExtendedAddress, KUidContactFieldVCardMapEXTENDEDADR); break; } case EPIMContactAddrStreet: { type = CContentType::NewL(KUidContactFieldAddress, KUidContactFieldVCardMapADR); break; } case EPIMContactAddrLocality: { type = CContentType::NewL(KUidContactFieldLocality, KUidContactFieldVCardMapLOCALITY); break; } case EPIMContactAddrRegion: { type = CContentType::NewL(KUidContactFieldRegion, KUidContactFieldVCardMapREGION); break; } case EPIMContactAddrPostalCode: { type = CContentType::NewL(KUidContactFieldPostcode, KUidContactFieldVCardMapPOSTCODE); break; } case EPIMContactAddrCountry: { type = CContentType::NewL(KUidContactFieldCountry, KUidContactFieldVCardMapCOUNTRY); break; } default: { User::Leave(KErrArgument); } } CleanupStack::PushL(type); // Add category if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } else if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } CleanupStack::Pop(type); return type; }