// ----------------------------------------------------------------------------- // CWPMessage::PrepareEntry // ----------------------------------------------------------------------------- // void CWPMessage::PrepareEntryLC( TMsvEntry& aEntry ) { FLOG( _L( "CWPMessage::PrepareEntryLC" ) ); // Current time TTime time; // Get Universal time time.UniversalTime(); FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry" ) ); // create an invisible blank entry aEntry.iType = KUidMsvMessageEntry; aEntry.SetVisible(EFalse); aEntry.SetInPreparation(ETrue); aEntry.SetReadOnly(EFalse); aEntry.SetUnread(ETrue); aEntry.iDate = time; aEntry.iServiceId = KMsvLocalServiceIndexEntryId; aEntry.iError = KErrNone; // iMtmData1 is been used/reserved for count, please don't use for any other purpose. aEntry.SetMtmData1(3); FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry done" ) ); // Look up the details HBufC* details = NULL; if( iMessage->Authenticated() ) { FLOG( _L( "CWPMessage::PrepareEntryLC iMessage->Authenticated() true" ) ); details = LoadStringLC( R_FROM_SERVICEPROVIDER ); FLOG( _L( "CWPMessage::PrepareEntryLC LoadString done" ) ); } else { FLOG( _L( "CWPMessage::PrepareEntryLC iMessage->Authenticated() false" ) ); if( iSender ) { FLOG( _L( "CWPMessage::PrepareEntryLC iSender true" ) ); details = HBufC::NewLC( iSender->Length() ); details->Des().Copy( *iSender ); } else { FLOG( _L( "CWPMessage::PrepareEntryLC iSender false" ) ); details = KNullDesC().AllocLC(); } } FLOG( _L( "CWPMessage::PrepareEntryLC iDetails.Set" ) ); aEntry.iDetails.Set( *details ); FLOG( _L( "CWPMessage::PrepareEntryLC Done" ) ); }
void CBulkCommitServerMtm::CreateBulkEntries(TUint aEntryCount, TMsvId aServiceId) { TMsvEntry newEntry; for (TInt i = 0; i < aEntryCount; ++i) { newEntry.iType = KUidMsvMessageEntry; newEntry.iMtm = KUidBulkCommitTestMtm; newEntry.iServiceId = aServiceId; newEntry.SetVisible(ETrue); newEntry.SetReadOnly(EFalse); newEntry.SetUnread(ETrue); newEntry.iDescription.Set(_L("Bulk Entry")); newEntry.SetSendingState(KMsvSendStateNotApplicable); iServerEntry->CreateEntryBulk(newEntry); } }
/* Creates two folders and then creates bulk entries under each folder. After bulk commit, creates an entry to let the client know about bulk commit is done. @param aEntryCount - Bulk entries to be created under each root entry */ void CBulkCommitServerMtm::CreateBulkEntryWithMultipleParentsL(TUint aEntryCount) { iServerEntry->SetEntry(iServiceId); TMsvEntry folderEntry1, folderEntry2; //create the first folder folderEntry1.iType=KUidMsvFolderEntry; folderEntry1.iMtm = KUidBulkCommitTestMtm; folderEntry1.iServiceId = iServiceId; iServerEntry->CreateEntry(folderEntry1); //create the second folder entry folderEntry2.iType=KUidMsvFolderEntry; folderEntry2.iMtm = KUidBulkCommitTestMtm; folderEntry2.iServiceId = iServiceId; iServerEntry->CreateEntry(folderEntry2); iServerEntry->SetEntry(folderEntry1.Id()); //Create a series of entries using the bulk API under the first folder CreateBulkEntries(aEntryCount, folderEntry1.Id()); iServerEntry->SetEntry(folderEntry2.Id()); //Create a series of entries using the bulk API under the second folder CreateBulkEntries(aEntryCount, folderEntry2.Id()); //commit the bulk entries iServerEntry->CompleteBulk(); iServerEntry->SetEntry(iServiceId); //Let the client know that the bulk commit is done TMsvEntry childEntry; childEntry.iType = KUidMsvMessageEntry; childEntry.iMtm = KUidBulkCommitTestMtm; childEntry.iServiceId = iServiceId; childEntry.SetVisible(ETrue); childEntry.SetReadOnly(EFalse); childEntry.SetUnread(ETrue); childEntry.iDescription.Set(_L("Bulk Commit Done")); childEntry.SetSendingState(KMsvSendStateNotApplicable); iServerEntry->CreateEntry(childEntry); //Set entry to NULL entry to avoid locking iServerEntry->SetEntry(KMsvNullIndexEntryId); }
TMsvId TestUniDataModelVCalPlugin::CreateBIOEntryL(TDesC& aText, TBIOMessageType aMessageType) { // Ensure that we have a valid service ID to work with: TMsvId iBioServiceId; iBioServiceId = SetBIOServiceIdL(); HBufC* localBuffer = aText.AllocL(); CleanupStack::PushL(localBuffer); TPtr messDes = localBuffer->Des(); if (aMessageType != EBiovCardMessage && aMessageType != EBiovCalenderMessage) { // convert \r\n to \n since this is what is expected from SMS when not vCard data for (TInt i = 0; i < messDes.Length(); i++) { if (messDes[i] == (TText) '\r' && i < messDes.Length() - 1 && messDes[i + 1] == (TText) '\n') messDes.Delete(i, 1); } } // Create and fill a CRichText object for the jobbie: CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer); CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer); CRichText* richText = CRichText::NewL(paraFormatLayer, charFormatLayer); CleanupStack::PushL(richText); TInt pos = richText->DocumentLength(); richText->InsertL(pos, messDes); TMsvEntry newBioEntry; newBioEntry.SetNew(ETrue); newBioEntry.SetComplete(EFalse); newBioEntry.SetUnread(ETrue); newBioEntry.SetVisible(ETrue); newBioEntry.SetReadOnly(EFalse); newBioEntry.SetFailed(EFalse); newBioEntry.SetOperation(EFalse); newBioEntry.SetMultipleRecipients(EFalse); newBioEntry.SetAttachment(EFalse); newBioEntry.iMtm = KUidBIOMessageTypeMtm; newBioEntry.iType = KUidMsvMessageEntry; newBioEntry.iServiceId = iBioServiceId; TTime now; now.UniversalTime(); newBioEntry.iDate = now; TTime unixEpoch(KUnixEpoch); TTimeIntervalSeconds seconds; TTime timeStamp = newBioEntry.iDate; timeStamp.SecondsFrom(unixEpoch, seconds); retTimeStamp.setTime_t(seconds.Int()); newBioEntry.iDescription.Set(richText->Read(0, richText->DocumentLength())); TBufC<KTelephoneNumberMaxLength> telNumber; QString recepient(TEST_MSG_FROM1); tempNumber = XQConversions::qStringToS60Desc(recepient); telNumber = tempNumber->Des(); newBioEntry.iDetails.Set(telNumber); SetForMtmTypeL(newBioEntry, aMessageType); newBioEntry.iSize = richText->DocumentLength();// msgSize; CreateBioEntryClientSideL(newBioEntry, *richText); CleanupStack::PopAndDestroy(4); // richText, charFormatLayer, paraFormatLayer, localBuffer return newBioEntry.Id(); }
void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId ) { CMsvEntry* messageEntry = iMsvSession->GetEntryL(aMessageId); CleanupStack::PushL(messageEntry); TMsvEntry entry = messageEntry->Entry(); if(entry.MtmData1() == KUidMsgTypeBtTInt32) { CMsvStore* store = messageEntry->ReadStoreL(); CleanupStack::PushL(store); TInt attachmentCount = store->AttachmentManagerL().AttachmentCount(); RFile attachmentFile; if(attachmentCount != 0) { //get file handle for the attachment & the complete path of the file attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = messageEntry->Entry(); attachEntry.SetUnread(EFalse); messageEntry->ChangeL(attachEntry); } else { CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL(*iMsvSession); CleanupStack::PushL(mtmReg); //1st Push CBIOClientMtm* bioClientMtm = (CBIOClientMtm*) mtmReg->NewMtmL(KBioUidValueUid); CleanupStack::PushL(bioClientMtm); //2nd Push bioClientMtm->SwitchCurrentEntryL(aMessageId); CMsvEntry* attachmentEntry = CMsvEntry::NewL(bioClientMtm->Session(), aMessageId, TMsvSelectionOrdering()); CleanupStack::PushL(attachmentEntry); //3rd Push bioClientMtm->LoadMessageL(); CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(selection); //4th Push selection->AppendL(aMessageId); TBuf8<1> aParameter; CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC(); //5th Push CMsvOperation* operation = bioClientMtm->InvokeAsyncFunctionL(KBiosMtmParse, *selection, aParameter, wait->iStatus); wait->Start(); CMsvStore* store = attachmentEntry->ReadStoreL(); CleanupStack::PushL(store); //6th Push MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); attachmentFile = attachMan.GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); //7th Push User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = attachmentEntry->Entry(); attachEntry.SetUnread(EFalse); attachmentEntry->ChangeL(attachEntry); delete operation; CleanupStack::PopAndDestroy(6); } CleanupStack::PopAndDestroy(store); } else { CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id()); CleanupStack::PushL(attachmentEntry); //1st push CMsvStore* store = attachmentEntry->ReadStoreL(); CleanupStack::PushL(store); //2nd push TBuf<KMaxPath> attachmentName(store->AttachmentManagerL().GetAttachmentInfoL(0)->AttachmentName()); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TEntry entry; User::LeaveIfError(fs.Entry(attachmentName, entry)); CleanupStack::PopAndDestroy(&fs); //get file handle for the attachment & the complete path of the file RFile attachmentFile; attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); //3rd Push User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = attachmentEntry->Entry(); attachEntry.SetUnread(EFalse); attachmentEntry->ChangeL(attachEntry); CleanupStack::PopAndDestroy(store); CleanupStack::PopAndDestroy(attachmentEntry); } CleanupStack::PopAndDestroy(messageEntry); }