00001 /* 00002 * ============================================================================ 00003 * Name : CPbkContactItem from CPbkContactItem.h 00004 * Part of : PbkEng.dll 00005 * 00006 * Description: 00007 * Phonebook Contact item class. 00008 * Version: 00009 * 00010 * Copyright (C) 2002 Nokia Corporation. 00011 * This material, including documentation and any related 00012 * computer programs, is protected by copyright controlled by 00013 * Nokia Corporation. All rights are reserved. Copying, 00014 * including reproducing, storing, adapting or translating, any 00015 * or all of this material requires the prior written consent of 00016 * Nokia Corporation. This material also contains confidential 00017 * information which may not be disclosed to others without the 00018 * prior written consent of Nokia Corporation. 00019 * ============================================================================ 00020 */ 00021 00022 #ifndef __CPbkContactItem_H__ 00023 #define __CPbkContactItem_H__ 00024 00025 // INCLUDES 00026 #include <e32base.h> // CBase, CArrayFixFlat 00027 #include "MPbkFieldData.h" // MPbkFieldDataArray 00028 #include "PbkFields.hrh" // TPbkFieldId 00029 #include "TPbkContactItemField.h" 00030 00031 // FORWARD DECLARATIONS 00032 class CPbkFieldsInfo; 00033 class CPbkFieldInfo; 00034 class CContactItemField; 00035 class CContactItem; 00036 class MPbkContactNameFormat; 00037 00038 00039 // CLASS DECLARATION 00040 00044 class CPbkFieldArray : public CArrayFixFlat<TPbkContactItemField> 00045 { 00046 public: 00047 enum 00048 { 00050 KDefaultGranularity = 8 00051 }; 00052 00056 inline CPbkFieldArray() 00057 : CArrayFixFlat<TPbkContactItemField>(KDefaultGranularity) 00058 { 00059 } 00060 00065 inline CPbkFieldArray(TInt aGranurality) 00066 : CArrayFixFlat<TPbkContactItemField>(aGranurality) 00067 { 00068 } 00069 }; 00070 00071 00078 class CPbkContactItem : 00079 public CBase, public MPbkFieldDataArray 00080 { 00081 public: // Constructor and destructor 00092 IMPORT_C static CPbkContactItem* NewL( 00093 CContactItem* aItem, 00094 const CPbkFieldsInfo& aFieldsInfo, 00095 MPbkContactNameFormat& aNameFormat); 00096 00100 ~CPbkContactItem(); 00101 00102 public: // CContactItem functions 00107 IMPORT_C TContactItemId Id() const; 00108 00115 IMPORT_C TUid Type() const; 00116 00122 IMPORT_C CContactIdArray* GroupsJoinedLC() const; 00123 00129 IMPORT_C CContactItem& ContactItem(); 00130 00136 IMPORT_C const CContactItem& ContactItem() const; 00137 00138 public: // Field set operations 00143 IMPORT_C CPbkFieldArray& CardFields() const; 00144 00151 IMPORT_C TPbkContactItemField& AddFieldL(CPbkFieldInfo& aFieldInfo); 00152 00160 IMPORT_C TBool CanAcceptDataOfType(CPbkFieldInfo& aFieldInfo) const; 00161 00175 IMPORT_C TPbkContactItemField* AddOrReturnUnusedFieldL 00176 (CPbkFieldInfo& aFieldInfo); 00177 00182 IMPORT_C void RemoveField(TInt aIndex); 00183 00192 IMPORT_C void UpdateFieldSetL(const CPbkFieldsInfo& aFieldsInfo); 00193 00194 public: // Field searching 00201 IMPORT_C TPbkContactItemField* FindField(TPbkFieldId aFieldId) const; 00202 00211 IMPORT_C TPbkContactItemField* FindField 00212 (TPbkFieldId aFieldId, TInt& aIndex) const; 00213 00220 IMPORT_C TPbkContactItemField* FindField(const CPbkFieldInfo& aFieldInfo) const; 00221 00230 IMPORT_C TPbkContactItemField* FindField 00231 (const CPbkFieldInfo& aFieldInfo, TInt& aIndex) const; 00232 00242 IMPORT_C TInt FindFieldIndex(const TPbkContactItemField& aField) const; 00243 00250 IMPORT_C TInt FindContactItemFieldIndex(const CContactItemField& aField) const; 00251 00265 IMPORT_C TPbkContactItemField* FindNextFieldWithPhoneNumber 00266 (const TDesC& aNumber, 00267 TInt aNumberOfDigits, 00268 TInt &aIndex) const; 00269 00280 IMPORT_C TPbkContactItemField* FindNextFieldWithText 00281 (const TDesC& aText, 00282 TInt& aIndex) const; 00283 00291 IMPORT_C TPbkContactItemField* FindSameField 00292 (const TPbkContactItemField& aField) const; 00293 00294 public: // Contact presentation 00302 IMPORT_C HBufC* GetContactTitleL() const; 00303 00310 IMPORT_C HBufC* GetContactTitleOrNullL() const; 00311 00318 IMPORT_C TPbkIconId ContactIconIdL() const; 00319 00320 public: // Defaults 00327 IMPORT_C TPbkContactItemField* DefaultPhoneNumberField() const; 00328 00338 IMPORT_C void SetDefaultPhoneNumberFieldL 00339 (TPbkContactItemField* aField); 00340 00346 IMPORT_C void RemoveDefaultPhoneNumberField(); 00347 00354 IMPORT_C TPbkContactItemField* DefaultVideoNumberField() const; 00355 00365 IMPORT_C void SetDefaultVideoNumberFieldL 00366 (TPbkContactItemField* aField); 00367 00373 IMPORT_C void RemoveDefaultVideoNumberField(); 00374 00381 IMPORT_C TPbkContactItemField* DefaultSmsField() const; 00382 00392 IMPORT_C void SetDefaultSmsFieldL(TPbkContactItemField* aField); 00393 00399 IMPORT_C void RemoveDefaultSmsField(); 00400 00407 IMPORT_C TPbkContactItemField* DefaultEmailField() const; 00408 00418 IMPORT_C void SetDefaultEmailFieldL(TPbkContactItemField* aField); 00419 00425 IMPORT_C void RemoveDefaultEmailField(); 00426 00433 IMPORT_C TPbkContactItemField* DefaultMmsField() const; 00434 00444 IMPORT_C void SetDefaultMmsFieldL(TPbkContactItemField* aField); 00445 00451 IMPORT_C void RemoveDefaultMmsField(); 00452 00459 IMPORT_C TPbkContactItemField* DefaultPocField() const; 00460 00470 IMPORT_C void SetDefaultPocFieldL(TPbkContactItemField* aField); 00471 00477 IMPORT_C void RemoveDefaultPocField(); 00478 00485 IMPORT_C TPbkContactItemField* DefaultVoipField() const; 00486 00496 IMPORT_C void SetDefaultVoipFieldL(TPbkContactItemField* aField); 00497 00503 IMPORT_C void RemoveDefaultVoipField(); 00504 00511 IMPORT_C TPbkContactItemField* DefaultEmailOverSmsField() const; 00512 00522 IMPORT_C void SetDefaultEmailOverSmsFieldL(TPbkContactItemField* aField); 00523 00529 IMPORT_C void RemoveDefaultEmailOverSmsField(); 00530 00531 public: // Voice tags 00541 IMPORT_C TPbkContactItemField* VoiceTagField() const; 00542 00553 IMPORT_C void SetVoiceTagFieldL(TPbkContactItemField* aField); 00554 00560 IMPORT_C void RemoveVoiceTagField(); 00561 00562 public: // from MPbkFieldDataArray 00563 TInt PbkFieldCount() const; 00564 MPbkFieldData& PbkFieldAt(TInt aIndex); 00565 const MPbkFieldData& PbkFieldAt(TInt aIndex) const; 00566 00567 public: // Phonebook internal functions, do not call 00574 void PrepareForSaveL(); 00575 00582 void PrepareAfterLoadL(); 00583 00584 private: // Implementation 00585 CPbkContactItem(MPbkContactNameFormat& aNameFormat); 00586 void ConstructL(CContactItem* aItem, const CPbkFieldsInfo& aFieldsInfo); 00587 void CreateFieldArrayL(CContactItem& aContactItem, const CPbkFieldsInfo& aFieldsInfo); 00588 TInt InsertionPos(const TPbkContactItemField& aField) const; 00589 __DECLARE_TEST; 00590 typedef CPbkContactItem SelfType; 00591 00592 private: // Data 00594 CContactItem* iItem; 00596 CPbkFieldArray iFields; 00598 MPbkContactNameFormat& iNameFormat; 00599 00600 private: // Friend declarations 00601 friend IMPORT_C TBool operator== 00602 (const CPbkContactItem& aLeft, const CPbkContactItem& aRight); 00603 }; 00604 00605 00606 // FUNCTION DECLARATIONS 00607 00611 IMPORT_C TBool operator== 00612 (const CPbkContactItem& aLeft, const CPbkContactItem& aRight); 00613 00617 inline TBool operator!= 00618 (const CPbkContactItem& aLeft, const CPbkContactItem& aRight) 00619 { 00620 return !(aLeft==aRight); 00621 } 00622 00623 00624 // __CPbkContactItem_H__ 00625 #endif 00626 00627 // End of File