00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "ContactWrite.h"
00018
00019 CContactWrite* CContactWrite::NewL()
00020 {
00021 CContactWrite* self = new (ELeave) CContactWrite();
00022 CleanupStack::PushL(self);
00023 self->ConstructL();
00024 CleanupStack::Pop(self);
00025 return self;
00026 }
00027
00028 CContactWrite::~CContactWrite()
00029 {
00030 delete iCntDb;
00031 }
00032
00033 void CContactWrite::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& CContactWrite::CntDatabase()
00047 {
00048 return *iCntDb;
00049 }
00050
00051 void CContactWrite::ExportContactL(TContactItemId aCntId,RWriteStream& aOutput)
00052 {
00053
00054 CContactIdArray* array = CContactIdArray::NewLC();
00055 array->AddL(aCntId);
00056 TUid uid;
00057 uid.iUid = KVersitEntityUidVCard;
00058 iCntDb->ExportSelectedContactsL(uid,*array,aOutput,CContactDatabase::EDefault);
00059 CleanupStack::PopAndDestroy(array);
00060 }
00061
00062 void CContactWrite::ImportContactL(RReadStream& aInput)
00063 {
00064 TBool success;
00065 CArrayPtr<CContactItem>* importedContacts = iCntDb->ImportContactsL(
00066 TUid::Uid(KVersitEntityUidVCard),aInput,success,
00067 CContactDatabase::EImportSingleContact |
00068 CContactDatabase::EIncludeX | CContactDatabase::ETTFormat);
00069
00070 delete importedContacts->At(0);
00071 delete importedContacts;
00072 }
00073
00074