00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "ContactRead.h"
00018
00019 CContactRead* CContactRead::NewL()
00020 {
00021 CContactRead* self = new (ELeave) CContactRead();
00022 CleanupStack::PushL(self);
00023 self->ConstructL();
00024 CleanupStack::Pop(self);
00025 return self;
00026 }
00027
00028 CContactRead::~CContactRead()
00029 {
00030 delete iCntDb;
00031 }
00032
00033 void CContactRead::ConstructL()
00034 {
00035 TRAPD(error, iCntDb = CContactDatabase::OpenL());
00036 if (KErrNotFound == error)
00037 {
00038 iCntDb = CContactDatabase::CreateL();
00039 }
00040 else
00041 {
00042 User::LeaveIfError(error);
00043 }
00044 }
00045
00046 CContactDatabase& CContactRead::CntDatabase()
00047 {
00048 return *iCntDb;
00049 }
00050
00051 CDesCArray* CContactRead::ReadTextFieldL(TContactItemId aCntId, TFieldType aType)
00052 {
00053 CDesCArray* result = new (ELeave) CDesCArrayFlat(2);
00054 CleanupStack::PushL(result);
00055 CContactItemViewDef* viewDef = CContactItemViewDef::NewLC(
00056 CContactItemViewDef::EIncludeFields,
00057 CContactItemViewDef::EMaskHiddenFields);
00058 viewDef->AddL(aType);
00059 CContactItem* item = iCntDb->ReadContactLC(aCntId, *viewDef);
00060 CContactItemFieldSet& fieldSet = item->CardFields();
00061
00062 for(TInt ii = 0 ; ii < fieldSet.Count() ; ++ii)
00063 {
00064 CContactItemField& field = fieldSet[ii];
00065 if (KStorageTypeText == field.StorageType())
00066 {
00067 if (field.TextStorage()->IsFull())
00068 {
00069 const TPtrC value = field.TextStorage()->Text();
00070 result->AppendL(value);
00071 }
00072 }
00073 }
00074
00075 CleanupStack::PopAndDestroy(item);
00076 CleanupStack::PopAndDestroy(viewDef);
00077 CleanupStack::Pop(result);
00078 return result;
00079 }
00080
00081