本文整理汇总了C++中CMsvEntry::EditStoreL方法的典型用法代码示例。如果您正苦于以下问题:C++ CMsvEntry::EditStoreL方法的具体用法?C++ CMsvEntry::EditStoreL怎么用?C++ CMsvEntry::EditStoreL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMsvEntry
的用法示例。
在下文中一共展示了CMsvEntry::EditStoreL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendPDUDataL
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CFakeSMSSender::AppendPDUDataL(TMsvId aEntryId, const TDesC& aRecipient,TBool aUnicodeMsg,const TDesC& aBody)
{
CMsvEntry* entry = iMsvSession->GetEntryL(aEntryId);
CleanupStack::PushL(entry);
CMsvStore* srore= entry->EditStoreL();
CleanupStack::PushL(srore);
if(srore)
{
CSmsBuffer* smsBuffer = CSmsBuffer::NewL();
CSmsMessage* smsMsg = CSmsMessage::NewL(iFsSession,CSmsPDU::ESmsDeliver, smsBuffer);
CleanupStack::PushL(smsMsg);
smsMsg->SetTime(entry->Entry().iDate);
if(aRecipient.Length() > 20)
smsMsg->SetToFromAddressL(aRecipient.Left(20));
else
smsMsg->SetToFromAddressL(aRecipient);
smsBuffer->InsertL(0,aBody);
CSmsDeliver& DSMSPDU = STATIC_CAST(CSmsDeliver&,smsMsg->SmsPDU());
DSMSPDU.SetMoreMessagesToSend(EFalse);
DSMSPDU.SetReplyPath(EFalse);
DSMSPDU.SetStatusReportIndication(EFalse);
TInt Hours(0x20);
DSMSPDU.SetServiceCenterTimeStamp(entry->Entry().iDate,Hours);
DSMSPDU.SetTextCompressed(EFalse);
DSMSPDU.SetPIDType(TSmsProtocolIdentifier::ESmsPIDShortMessageType);
//DSMSPDU.SetTextCompressed(TBool aCompressed);
//DSMSPDU.SetAlphabet(TSmsDataCodingScheme::TSmsAlphabet aAlphabet);
CSmsHeader* MyHeader = CSmsHeader::NewL(smsMsg);
CleanupStack::Pop(1);//smsMsg
CleanupStack::PushL(MyHeader);
CSmsSettings* MySetting = CSmsSettings::NewL();
CleanupStack::PushL(MySetting);
if(aUnicodeMsg)
MySetting->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabetUCS2);
else
MySetting->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet7Bit);
//MySetting->StoreL(*srore);//InternalizeL
MyHeader->SetSmsSettingsL(*MySetting);
MyHeader->StoreL(*srore);
srore->CommitL();
CleanupStack::PopAndDestroy(2);//MySetting,MyHeader,
}
CleanupStack::PopAndDestroy(2);//entry,srore
}
示例2: ForwardL
CMsvOperation* CTextMtmClient::ForwardL(TMsvId aForwardEntryId, TMsvPartList aPartList,
TRequestStatus& aCompletionStatus)
// Create forwarded message
// Destination folder is aForwardEntryL
//
{
__ASSERT_DEBUG(iMsvEntry!=NULL,gPanic(ETxtcNoCMsvEntrySet));
__ASSERT_DEBUG(iMsvEntry->Entry().iType.iUid == KUidMsvMessageEntryValue, gPanic(ETxtcEntryTypeNotSupported));
__ASSERT_DEBUG(iMsvEntry->Entry().iServiceId == KMsvLocalServiceIndexEntryId, gPanic(ETxtcInvalidServiceId));
// Create the forwarded index entry
TMsvEntry forwardEntry;
forwardEntry.iMtm = KUidMsgTypeText;
forwardEntry.iServiceId = Entry().Entry().iServiceId;
forwardEntry.iType = KUidMsvMessageEntry;
forwardEntry.iDetails.Set(iMsvEntry->Entry().iDetails);
forwardEntry.iSize = iMsvEntry->Entry().iSize;
if(aPartList&KMsvMessagePartDate)
forwardEntry.iDate.HomeTime();
if(aPartList&KMsvMessagePartDescription)
forwardEntry.iDescription.Set(iMsvEntry->Entry().iDescription);
// Get CMsvEntry for destination (parent)
CMsvEntry* cEntry = CMsvEntry::NewL(Session(), aForwardEntryId, TMsvSelectionOrdering());
CleanupStack::PushL(cEntry);
// Synchronously create new child
CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC();
CMsvOperation* opert = cEntry->CreateL(forwardEntry, wait->iStatus);
CleanupStack::PushL(opert);
wait->Start();
User::LeaveIfError(opert->iStatus.Int());
// Check result
TPckgBuf<TMsvLocalOperationProgress> progressPack;
progressPack.Copy(opert->ProgressL());
TMsvLocalOperationProgress progress = progressPack();
User::LeaveIfError(progress.iError);
CleanupStack::PopAndDestroy(2); // opert, wait
// Get CMsvEntry for new entry
TMsvId forwardId=progress.iId;
cEntry->SetEntryL(forwardId);
// Populate new forwarded message with Body text
if(aPartList&KMsvMessagePartBody)
{
CMsvStore* store=cEntry->EditStoreL();
CleanupStack::PushL(store);
StoreBodyL(*store); // Current context is original message
store->CommitL();
CleanupStack::PopAndDestroy(); // store
}
CleanupStack::PopAndDestroy(); // cEntry
// Request was performed synchronously, so return a completed operation object
return CMsvCompletedOperation::NewL(Session(), KUidMsgTypeText, progressPack,
KMsvNullIndexEntryId, aCompletionStatus);
}
示例3: StoreMsgL
// -----------------------------------------------------------------------------
// CWPMessage::StoreMsgL
// -----------------------------------------------------------------------------
//
void CWPMessage::StoreMsgL()
{
FLOG( _L( "CWPMessage::StoreMsgL" ) );
// create an invisible blank entry
TMsvEntry entry;
PrepareEntryLC( entry ); // details on cleanup stack
entry.iBioType = iBioUID.iUid;
entry.iMtm = KUidBIOMessageTypeMtm;
// Look up and set the description
FLOG( _L( "CWPMessage::StoreMsgL 1" ) );
TInt index;
CBIODatabase* bioDB = CBIODatabase::NewLC( iSession->FileSession() );
FLOG( _L( "CWPMessage::StoreMsgL 2" ) );
TRAPD( err, bioDB->GetBioIndexWithMsgIDL( iBioUID, index ) );
if (err ==KErrNone)
{
FLOG( _L( "CWPMessage::StoreMsgL 3" ) );
HBufC* description = bioDB->BifReader(index).Description().AllocL();
FLOG( _L( "CWPMessage::StoreMsgL 4" ) );
entry.iDescription.Set(*description);
FLOG( _L( "CWPMessage::StoreMsgL 5" ) );
CleanupStack::PopAndDestroy(); // bioDB
CleanupStack::PushL( description );
}
else
{
FTRACE(RDebug::Print(_L(" CWPMessage::StoreMsgL err (%d)"), err));
CleanupStack::PopAndDestroy(); // bioDB
}
FLOG( _L( "CWPMessage::StoreMsgL 6" ) );
// Store entry in inbox
CMsvEntry* msvEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId );
FLOG( _L( "CWPMessage::StoreMsgL 7" ) );
CleanupStack::PushL(msvEntry);
msvEntry->CreateL(entry);
msvEntry->Session().CleanupEntryPushL(entry.Id());
msvEntry->SetEntryL(entry.Id());
FLOG( _L( "CWPMessage::StoreMsgL 8" ) );
// Save the message
CMsvStore* store = msvEntry->EditStoreL();
CleanupStack::PushL(store);
FLOG( _L( "CWPMessage::StoreMsgL 9" ) );
iMessage->StoreL( *store );
store->CommitL();
// Complete processing the message
PostprocessEntryL( *msvEntry, entry );
CleanupStack::PopAndDestroy(); //store
msvEntry->Session().CleanupEntryPop(); //entry
CleanupStack::PopAndDestroy(3); //description, details, msvEntry
FLOG( _L( "CWPMessage::StoreMsgL Done" ) );
}
示例4: TestReadOnlyDeletionL
LOCAL_C void TestReadOnlyDeletionL()
{
CDummyObserver* ob = new(ELeave)CDummyObserver;
CleanupStack::PushL(ob);
CMsvSession* session = CMsvSession::OpenSyncL(*ob);
CleanupStack::PushL(session);
CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering());
CleanupStack::PushL(cEntry);
// Create an entry
TMsvEntry entry;
entry.iType = KUidMsvMessageEntry;
entry.iMtm = KUidMsvLocalServiceMtm;
entry.iServiceId = KMsvLocalServiceIndexEntryId;
cEntry->CreateL(entry);
// Generate name of attachment
cEntry->SetEntryL(entry.Id());
TFileName fileName;
fileName.Append(_L("Test"));
CMsvStore* store = cEntry->EditStoreL();
CleanupStack::PushL(store);
CAsyncWaiter* waiter = CAsyncWaiter::NewL();
CleanupStack::PushL(waiter);
CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
CleanupStack::PushL(attachment);
fileName.Append(_L("Test"));
attachment->SetAttachmentNameL(fileName);
RFile file;
store->AttachmentManagerL().CreateAttachmentL(fileName, file, attachment, waiter->iStatus);
CleanupStack::Pop(attachment); // ownership passed
waiter->StartAndWait();
User::LeaveIfError(waiter->Result());
CleanupStack::PopAndDestroy(waiter);
CleanupClosePushL(file);
User::LeaveIfError(file.Write(_L8("some text")));
User::LeaveIfError(file.SetAtt(KEntryAttReadOnly, KEntryAttNormal));
CleanupStack::PopAndDestroy(2, store); // file, store
// Now try and delete the file
cEntry->SetEntryL(entry.Parent());
cEntry->DeleteL(entry.Id());
CleanupStack::PopAndDestroy(3); // cEntry, session, ob
}
示例5: UpdateEntryL
void CMsvSendExe::UpdateEntryL(CMsvEntry& aMsvEntry, TMsvEntry& aEntry, const TSchedulerItemRef& aRef, const TTaskInfo& aInfo, const TTime& aStartTime)
{
CMsvStore* store = aMsvEntry.EditStoreL();
CleanupStack::PushL(store);
TMsvEntryScheduleData data;
data.RestoreL(*store);
CMsvScheduleSend::UpdateEntryAfterSchedule(aRef, aInfo, aStartTime, KMsvSendStateResend, aEntry, data);
data.StoreL(*store);
store->CommitL();
CleanupStack::PopAndDestroy(store);
aMsvEntry.ChangeL(aEntry);
}
示例6: ExecuteActionL
void CMtfTestActionRemoveAllAttachments::ExecuteActionL()
{
TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionRemoveAllAttachments);
CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
TInt attachIdFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2), 0);
CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
CleanupStack::PushL(entry);
CMsvStore* store = entry->EditStoreL();
CleanupStack::PushL(store);
MMsvAttachmentManager& manager = store->AttachmentManagerL();
TInt attachmentCount = manager.AttachmentCount();
for ( ; attachmentCount > 0 ; attachmentCount-- )
{
CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
CleanupStack::PushL(waiter);
if( attachIdFlag == 1 )
{
CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(0);
CleanupStack::PushL(attachInfo);
manager.RemoveAttachmentL(attachInfo->Id(), waiter->iStatus);
CleanupStack::PopAndDestroy(attachInfo);
}
else
{
manager.RemoveAttachmentL(0, waiter->iStatus);
}
waiter->StartAndWait();
User::LeaveIfError(waiter->Result());
CleanupStack::PopAndDestroy(waiter);
}
store->CommitL();
CleanupStack::PopAndDestroy(2, entry); // store, entry
TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionRemoveAllAttachments);
TestCase().ActionCompletedL(*this);
}
示例7: FinalizeMessageL
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CFakeSMSSender::FinalizeMessageL(TMsvId aEntryId,const TDesC& aBody,const TDesC& aRecipientName,TTime aMsgTime)
{
CMsvEntry* entry = iMsvSession->GetEntryL(aEntryId);
CleanupStack::PushL(entry);
TMsvEntry newEntry(entry->Entry()); // This represents an entry in the Message Server index
newEntry.SetInPreparation(EFalse); // a flag that this message is in preparation
newEntry.iDetails.Set(aRecipientName);
newEntry.SetUnread(ETrue);
newEntry.iDate = aMsgTime;
newEntry.SetReadOnly(ETrue);
CMsvStore* srore = entry->EditStoreL();
CleanupStack::PushL(srore);
if(srore)
{
CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
CleanupStack::PushL(paraFormatLayer);
CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
CleanupStack::PushL(charFormatLayer);
CRichText* messageBodyContent = CRichText::NewL(paraFormatLayer, charFormatLayer);
CleanupStack::PushL(messageBodyContent);
messageBodyContent->InsertL(0,aBody);
srore->StoreBodyTextL(*messageBodyContent);
srore->CommitL();
CleanupStack::PopAndDestroy(3); // messageBodyContent, charFormatLayer,paraFormatLayer
if(aBody.Length() > 50)
newEntry.iDescription.Set(aBody.Left(50));
else
newEntry.iDescription.Set(aBody);
}
CleanupStack::PopAndDestroy(srore);
entry->ChangeL(newEntry);
entry->MoveL(aEntryId,KMsvGlobalInBoxIndexEntryId);
CleanupStack::PopAndDestroy(entry);
}
示例8: SaveL
/**
Stores the Unknown Push message in the message store.
Saves the message data in a new attachment file. This makes it more efficient for the UI
to read the data.
@param aSession
Message server session
@param aParent
ID of the parent for the new entry. It is the caller's responsibility to ensure
that the parent ID is correct.
@return
ID of the new message server entry.
@see CPushMsgEntryBase::SaveL()
*/
EXPORT_C TMsvId CUnknownPushMsgEntry::SaveL(CMsvSession& aSession, TMsvId aParent)
{
CMsvEntry* entryPtr = aSession.GetEntryL(KMsvRootIndexEntryId);
CleanupStack::PushL(entryPtr);
// This tidies itself up
TMsvId newEntry = CPushMsgEntryBase::SaveL(aSession, aParent);
#ifdef __MESSAGING_API_V2__
TRAPD(
saveError,
TFileName fileName = ContentFileNameL();
entryPtr->SetEntryL(newEntry);
CMsvStore* store = entryPtr->EditStoreL();
CleanupStack::PushL(store);
SaveMessageBodyL(store->AttachmentManagerL(), fileName);
store->CommitL();
CleanupStack::PopAndDestroy(store);
)
示例9: RunTestL
void CMtfTestActionAddEntryAttachment::RunTestL()
{
CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
TMsvId attachmentMessageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2));
CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
CleanupStack::PushL(entry);
CMsvStore* store = entry->EditStoreL();
CleanupStack::PushL(store);
CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
CleanupStack::PushL(waiter);
CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvMessageEntry);
CleanupStack::PushL(attachment);
TMsvEntry attachmentEntry;
TMsvId attachmentServiceEntry;
User::LeaveIfError(paramSession->GetEntry(attachmentMessageEntry, attachmentServiceEntry, attachmentEntry));
attachment->SetSize(attachmentEntry.iSize);
MMsvAttachmentManager& manager = store->AttachmentManagerL();
manager.AddEntryAsAttachmentL(attachmentMessageEntry, attachment, waiter->iStatus);
CleanupStack::Pop(attachment); // ownership passed to manager
waiter->StartAndWait();
User::LeaveIfError(waiter->Result());
CleanupStack::PopAndDestroy(waiter);
TMsvAttachmentId attachmentId = attachment->Id();
store->CommitL();
CleanupStack::PopAndDestroy(2, entry); // store, entry
StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(3));
}
示例10: ExecuteActionL
void CMtfTestActionRemoveFileAttachmentWithDestroy::ExecuteActionL()
{
TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionRemoveFileAttachmentWithDestroy);
CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
TMsvAttachmentId attachId = ObtainValueParameterL<TMsvAttachmentId>(TestCase(),ActionParameters().Parameter(2));
CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
CleanupStack::PushL(entry);
CMsvStore* store = entry->EditStoreL();
CleanupStack::PushL(store);
MMsvAttachmentManager& manager = store->AttachmentManagerL();
CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(attachId);
CleanupStack::PushL(attachInfo);
// First ensure that the attachment is a file attachment
if( attachInfo->Type() != CMsvAttachment::EMsvFile )
{
User::Leave(KErrGeneral);
}
CleanupStack::PopAndDestroy(attachInfo);
CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
CleanupStack::PushL(waiter);
manager.RemoveAttachmentL(attachId, waiter->iStatus);
waiter->StartAndWait();
User::LeaveIfError(waiter->Result());
CleanupStack::PopAndDestroy(waiter);
// destroy the store without commit
CleanupStack::PopAndDestroy(2, entry); // store, entry
TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionRemoveFileAttachmentWithDestroy);
TestCase().ActionCompletedL(*this);
}
示例11: doTestStepL
TVerdict CCreateSmsMessageTestStep::doTestStepL()
{
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
CActiveScheduler::Install(scheduler);
CleanupStack::PushL(scheduler);
CSessionObserver* sessionObserver = new (ELeave) CSessionObserver;
CleanupStack::PushL(sessionObserver);
CMsvSession* session = CMsvSession::OpenSyncL(*sessionObserver);
CleanupStack::PushL(session);
_LIT(KFileName,"FileName");
TPtrC tag;
if ( !GetStringFromConfig(ConfigSection(),KFileName,tag))
{
ERR_PRINTF1(_L("No Input for FileName in CreateSmsMessage"));
User::Leave(KErrNotReady);
}
HBufC* fileName = tag.AllocLC();
// Create a Rich Text object
CPlainText::TTextOrganisation ttOrg = {CPlainText::EOrganiseByLine};
CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
CleanupStack::PushL(paraFormatLayer);
CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
CleanupStack::PushL(charFormatLayer);
CRichText* bodyRichText = CRichText::NewL(paraFormatLayer, charFormatLayer);
CleanupStack::PushL(bodyRichText);
// Store the file contents into the CRichText object
bodyRichText->ImportTextFileL(0, fileName->Des(), ttOrg);
// Create the SMS header object...
CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *bodyRichText);
CleanupStack::PushL(header);
// Set the body text...
CSmsSettings* smsSettings = CSmsSettings::NewL();
CleanupStack::PushL(smsSettings);
CSmsAccount* account = CSmsAccount::NewLC();
account->LoadSettingsL(*smsSettings);
// Copy the message settings...
header->SetSmsSettingsL(*smsSettings);
// Set the service centre
TInt defaultIndex = smsSettings->DefaultServiceCenter();
header->SetServiceCenterAddressL(smsSettings->GetServiceCenter(defaultIndex).Address());
// Set recipient - ask derived class
SetRecipientsL(*header);
CArrayPtrFlat<CSmsNumber>& recipient = header->Recipients();
INFO_PRINTF1(_L("Creating message..."));
TMsvEntry entry;
entry.SetVisible(ETrue);
entry.SetInPreparation(ETrue);
TMsvId srvcId=0;
TSmsUtilities::ServiceIdL(*session, srvcId);
entry.iServiceId = srvcId;
entry.iType = KUidMsvMessageEntry;
entry.iMtm = KUidMsgTypeSMS;
entry.iDate.UniversalTime();
entry.iSize = 0;
entry.iDescription.Set(KNullDesC);
entry.iDetails.Set(KNullDesC);
entry.SetSendingState(KMsvSendStateWaiting);
// Update entry description and details...
entry.iDetails.Set(recipient[0]->Address());
entry.iDescription.Set(recipient[0]->Address());
entry.SetInPreparation(EFalse);
//TPtrC tag;
_LIT(KParent,"Parent");
TPtrC parentTag;
if ( !GetStringFromConfig(ConfigSection(),KParent,parentTag))
{
ERR_PRINTF1(_L("No Input for Outbox"));
User::Leave(KErrNotReady);
}
// Create the entry - set context to the global outbox.
TMsvId paramParentId = MsgingUtils::GetLocalFolderId(parentTag);//KMsvGlobalOutBoxIndexEntryId;
CMsvEntry* newEntry = CMsvEntry::NewL(*session,paramParentId,TMsvSelectionOrdering());
CleanupStack::PushL(newEntry);
newEntry->SetEntryL(paramParentId);
newEntry->CreateL(entry);
// Create new store and save header information
newEntry->SetEntryL(entry.Id());
CMsvStore* store = newEntry->EditStoreL();
CleanupStack::PushL(store);
//.........这里部分代码省略.........
示例12: PrepareStoreL
// ----------------------------------------------------------------------------
// CIpsPlgNewChildPartFromFileOperation::PrepareStoreL
// ----------------------------------------------------------------------------
//
void CIpsPlgNewChildPartFromFileOperation::PrepareStoreL()
{
CMsvEntry* cAtta = iMsvSession.GetEntryL( iNewAttachmentId );
CleanupStack::PushL( cAtta );
TBool parentToMultipartAlternative( EFalse );
if( cAtta->HasStoreL() )
{
CMsvStore* store = cAtta->EditStoreL();
CleanupStack::PushL( store );
CImMimeHeader* mimeHeader = CImMimeHeader::NewLC();
if( store->IsPresentL( KUidMsgFileMimeHeader ) )
{
mimeHeader->RestoreL( *store );
CDesC8Array& array = mimeHeader->ContentTypeParams();
array.AppendL( KMethod );
parentToMultipartAlternative = ETrue;
if( iContentType->Des().Find( KMimeTextCalRequest ) != KErrNotFound )
{
array.AppendL( KRequest );
}
else if( iContentType->Des().Find( KMimeTextCalResponse ) != KErrNotFound )
{
array.AppendL( KResponse );
}
else if( iContentType->Des().Find( KMimeTextCalCancel ) != KErrNotFound )
{
array.AppendL( KCancel );
}
else
{
parentToMultipartAlternative = EFalse;
}
mimeHeader->StoreWithoutCommitL( *store );
store->CommitL();
}
CleanupStack::PopAndDestroy( 2, store );
}
if( parentToMultipartAlternative &&
iFilePath->Find( KFileExtensionICS ) != KErrNotFound )
{
TMsvEntry tAttaEntry = cAtta->Entry();
TMsvId id = tAttaEntry.Parent();
CMsvEntry* cParent = iMsvSession.GetEntryL( id );
CleanupStack::PushL( cParent );
TMsvEmailEntry tEntry = cParent->Entry();
tEntry.SetMessageFolderType( EFolderTypeAlternative );
// Do async again if needed
iOperation = cParent->ChangeL( tEntry, iStatus );
CleanupStack::PopAndDestroy( cParent );
CleanupStack::PopAndDestroy( cAtta );
}
else
{
CleanupStack::PopAndDestroy( cAtta );
iStatus = KRequestPending;
TRequestStatus* status = &iStatus;
User::RequestComplete(status,KErrNone);
}
iStep = EStoreMessagePart; // Next step
SetActive();
}
示例13: StoreL
//
// StoreL() - Store bookmarks as an attachment file
// in the .eBM format. If the system runs out of memory while
// the bookmarks are being written to the file, the file will be
// deleted. For example, if 2 bookmarks have already been written
// to the file, and the writing of the third bookmark fails, the
// file will be deleted. Otherwise, a failure of file writing would
// need to be handled differently from memory allocation failure.
//
void CWWWHotlistParser::StoreL(CMsvEntry& aEntry)
{
TInt numberOfItems = iHotlistItemList->Count();
if (numberOfItems>0) // Only create a file if there is something to save!
{
// Generate fileName from msgId and bookmark file extension.
// The file name consists of the msgId in hex format
// followed by .eBM. Sizeof operator returns the size of msgId
// in bytes and each byte requires 2 hex digits to represent it,
// hence sizeof is multipled by 2. Didn't want to make
// fileNameLength constant because the size of TMsvId may change
// in the future.
TMsvId entryId = aEntry.Entry().Id();
TInt fileNameLength = 2*sizeof(entryId) +
KEBookmarkExtension().Length();
HBufC *fileName = HBufC::NewLC(fileNameLength);
TPtr fileNameDes = fileName->Des();
// The file name uses the hex representation of the entry Id.
// If this changes to some other representation then
// fileNameLength will need to be calculated differently.
fileNameDes.Num(entryId,EHex);
fileNameDes.Append(KEBookmarkExtension);
// Get the attachment manager and create an empty attachment file
CMsvStore* store = aEntry.EditStoreL();
CleanupStack::PushL(store);
MMsvAttachmentManagerSync& managerSync = store->AttachmentManagerExtensionsL();
CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
CleanupStack::PushL(attachment);
attachment->SetAttachmentNameL(*fileName);
RFile file;
managerSync.CreateAttachmentL(*fileName, file, attachment);
CleanupStack::Pop(attachment); // ownership passed
CleanupClosePushL(file);
#ifdef SYMBIAN_BOOKMARK_DATABASE
// Open the bookmark database ready to add the bookmarks
RBkDatabase bookmarkDb;
bookmarkDb.OpenL();
CleanupClosePushL(bookmarkDb);
#endif // SYMBIAN_BOOKMARK_DATABASE
// Stream each bookmark into the file.
// The eBookmark file must contain only 8bit ascii.
// Add a linefeed to the end of each line.
for(TInt count=0; count < numberOfItems; count++)
{
CWWWHotlistItem &item = *iHotlistItemList->At(count);
// Allocate enough space to hold the full bookmark entry.
TInt length = item.Name().Length() +
item.Url().Length() +
KEBookmarkConstantChars;
HBufC8 *writeBuf = HBufC8::NewLC(length);
TPtr8 des = writeBuf->Des();
des.Append(KEBookmarkItemBegin);
des.Append(KEBookmarkItemURL);
des.Append(item.Url());
des.Append(KCRLinefeed);
des.Append(KEBookmarkItemName);
des.Append(item.Name());
des.Append(KCRLinefeed);
des.Append(KEBookmarkType);
des.Append(KEBookmarkItemEnd);
User::LeaveIfError(file.Write(des));
CleanupStack::PopAndDestroy();
#ifdef SYMBIAN_BOOKMARK_DATABASE
// Add the bookmark to the bookmark database
RBkBookmark bookmark = bookmarkDb.CreateBookmarkL();
CleanupClosePushL(bookmark);
bookmark.SetTitleL(item.Name());
// Convert Uri to 8-bit
HBufC8* bookmarkUri = HBufC8::NewLC(item.Url().Length());
//.........这里部分代码省略.........
示例14: ExecuteActionL
//.........这里部分代码省略.........
TBuf8<1> aChar; // To read one character from the file
TBool finished = FALSE;
recvConvert->ResetL();
// Parse each line from the
do {
line.FillZ();
line.SetLength(0);
// Read one line from email file
do {
file.Read(aChar, 1);
if(aChar.Length())
{
line.Append(aChar);
}
else
{
finished = TRUE;
}
} while(aChar.Length() && aChar[0] != 0x0A);
if(!line.Length())
{
break;
}
// Parse the line for the fields of the email and store them
recvConvert->ParseNextFieldL(line);
} while(!finished);
/****************************************************************************
Complete the message creation by setting all the required fields and
storing the email on to the message store.
The created email's ID is returned by MessageCompelteL function
****************************************************************************/
TMsvId paramMessageId;
paramMessageId = recvConvert->MessageCompleteL();
if(paramMessageId == 0)
{
User::Leave(KErrUnknown);
}
file.Close();
CleanupStack::PopAndDestroy(recvConvert);
if(overrideAddress)
{
#ifndef __MESSAGING_API_V2__
entry->SetEntryL(paramServiceId);
CMsvStore* store=entry->ReadStoreL();
CleanupStack::PushL(store);
#endif
CImSmtpSettings* settings= new(ELeave) CImSmtpSettings();
CleanupStack::PushL(settings);
#ifdef __MESSAGING_API_V2__
CEmailAccounts* accounts = CEmailAccounts::NewLC();
TSmtpAccount smtpAccount;
accounts->GetSmtpAccountL(paramServiceId, smtpAccount);
accounts->LoadSmtpSettingsL(smtpAccount, *settings);
CleanupStack::PopAndDestroy();
#else
settings->RestoreL(*store);
CleanupStack::PopAndDestroy();
#endif
HBufC* emailAddress=settings->EmailAddress().AllocL();
CleanupStack::PopAndDestroy();
CleanupStack::PushL(emailAddress);
entry->SetEntryL(paramMessageId);
#ifdef __MESSAGING_API_V2__
CMsvStore* store=entry->EditStoreL();
#else
store=entry->EditStoreL();
#endif
CleanupStack::PushL(store);
CImHeader* header= CImHeader::NewLC();
header->RestoreL(*store);
header->ToRecipients().Reset();
header->ToRecipients().AppendL(*emailAddress);
header->StoreL(*store);
store->CommitL();
CleanupStack::PopAndDestroy(3,emailAddress);
}
CleanupStack::PopAndDestroy(entry);
TestCase().INFO_PRINTF2(_L("Created a email from file %S"),&fileName);
StoreParameterL<TMsvId>(TestCase(),paramMessageId,ActionParameters().Parameter(4));
fs.Close();
TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateSmtpMessageFromEmailFile);
TestCase().ActionCompletedL(*this);
}
示例15: CreateMessageL
//.........这里部分代码省略.........
RFile infile;
User::LeaveIfError(infile.Open(fsSession, aBody, EFileRead));
TInt size;
TInt err=infile.Size(size);
HBufC8* filebuf;
filebuf = HBufC8::NewLC(size);
TPtr8 ptr8=filebuf->Des();
infile.Read(ptr8);
HBufC* filebuf16;
filebuf16 = HBufC::NewLC(size);
TPtr ptr16=filebuf16->Des();
ptr16.Copy(ptr8);
//insert the body text
bodyText->InsertL(0, ptr16);
infile.Close();
fsSession.Close();
CleanupStack::PopAndDestroy(2,filebuf);
}
for(TInt i=0;i<aCount;i++)
{
//create the message
TMsvPartList partList = KMsvMessagePartBody;
CImEmailOperation* emailOp = CImEmailOperation::CreateNewL(iTestActive->iStatus,*iSession,aTMsvId,partList,0,KUidMsgTypeSMTP);
CleanupStack::PushL(emailOp);
// Active object which stops the active scheduler
iTestActive->StartL();
CActiveScheduler::Start();
// Get the new message id.
TMsvId messageId;
TPckg<TMsvId> param(messageId);
param.Copy(emailOp->FinalProgress());
CleanupStack::PopAndDestroy(emailOp);
// Save the message body text
TMsvSelectionOrdering ordering;
CMsvEntry* entry = CMsvEntry::NewL(*iSession, messageId,ordering);
CleanupStack::PushL(entry);
CImEmailMessage* message = CImEmailMessage::NewL(*entry);
CleanupStack::PushL(message);
//add attachments
if(aAttachment1!=KNullFileName)
{
CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
CleanupStack::PushL(attachmentInfo);
message->AttachmentManager().AddAttachmentL(aAttachment1, attachmentInfo, iTestActive->iStatus);
CleanupStack::Pop(attachmentInfo);
iTestActive->StartL();
CActiveScheduler::Start(); // wait for the asynch operation to complete
}
if(aAttachment2!=KNullFileName)
{
CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
CleanupStack::PushL(attachmentInfo);
message->AttachmentManager().AddAttachmentL(aAttachment2, attachmentInfo, iTestActive->iStatus);
CleanupStack::Pop(attachmentInfo);
iTestActive->StartL();
CActiveScheduler::Start(); // wait for the asynch operation to complete
}
if(aAttachment3!=KNullFileName)
{
CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
CleanupStack::PushL(attachmentInfo);
message->AttachmentManager().AddAttachmentL(aAttachment3, attachmentInfo, iTestActive->iStatus);
CleanupStack::Pop(attachmentInfo);
iTestActive->StartL();
CActiveScheduler::Start(); // wait for the asynch operation to complete
}
iTestActive->StartL();
message->StoreBodyTextL(messageId, *bodyText, iTestActive->iStatus);
CActiveScheduler::Start();
CleanupStack::PopAndDestroy(message);
// fill in header details for email message
CMsvStore* store = entry->EditStoreL();
CleanupStack::PushL(store);
CImHeader* header = CImHeader::NewLC();
header->RestoreL(*store);
header->ToRecipients().AppendL(aAddress);
header->SetSubjectL(aSubject);
header->StoreL(*store);
store->CommitL();
CleanupStack::PopAndDestroy(3,entry);
}
CleanupStack::PopAndDestroy(3,paraFormatLayer);
}