本文整理汇总了C++中CMsvAttachment类的典型用法代码示例。如果您正苦于以下问题:C++ CMsvAttachment类的具体用法?C++ CMsvAttachment怎么用?C++ CMsvAttachment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMsvAttachment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartL
void CAddObexAttachmentAsEntryState::StartL(TRequestStatus& aStatus)
{
// Add an attachment as a child entry
CBaseMtm& clientMtm = iClientTest.ObexTestUtils().GetCurrentObexClientMtm();
CMsvEntry& entry = clientMtm.Entry();
CMsvStore* store = entry.EditStoreL();
CleanupStack::PushL(store);
CAsyncWaiter* waiter = CAsyncWaiter::NewL();
CleanupStack::PushL(waiter);
CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
CleanupStack::PushL(attachment);
TParse fileNameParser;
User::LeaveIfError(fileNameParser.Set(iFileName, NULL, NULL));
attachment->SetAttachmentNameL(fileNameParser.NameAndExt());
store->AttachmentManagerL().AddAttachmentL(iFileName, attachment, waiter->iStatus);
CleanupStack::Pop(attachment);
waiter->StartAndWait();
User::LeaveIfError(waiter->Result());
CleanupStack::PopAndDestroy(waiter);
store->CommitL();
CleanupStack::PopAndDestroy(store);
TRequestStatus* status = &aStatus;
User::RequestComplete(status, KErrNone);
}
示例2: while
// ---------------------------------------------------------
//
// ---------------------------------------------------------
void CMmsAttachmentHandler::RemoveAttachmentL( TMsvAttachmentId aAttaId, CMsvStore& aStore )
{
MMsvAttachmentManager& attaMan = aStore.AttachmentManagerL();
MMsvAttachmentManagerSync& attaManSync = aStore.AttachmentManagerExtensionsL();
// can only remove synchronously if index is known.
TInt count = attaMan.AttachmentCount();
TInt i = count - 1;
TBool found = EFalse;
while ( i >= 0 && !found )
{
CMsvAttachment* attachmentInfo = attaMan.GetAttachmentInfoL( i );
CleanupStack::PushL( attachmentInfo );
if ( attachmentInfo->Id() == aAttaId )
{
found = ETrue;
}
else
{
i--;
}
CleanupStack::PopAndDestroy( attachmentInfo );
attachmentInfo = NULL;
}
if ( i >= 0 && found )
{
attaManSync.RemoveAttachmentL( i );
}
}
示例3: RunTestL
void CMtfTestActionAddAttachmentAsLink::RunTestL()
{
CMsvStore* paramStore = ObtainParameterReferenceL<CMsvStore>(TestCase(),ActionParameters().Parameter(0));
HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1));
HBufC8* paramMimeType = ObtainParameterReferenceL<HBufC8>(TestCase(),ActionParameters().Parameter(2));
CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
CleanupStack::PushL(waiter);
CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
CleanupStack::PushL(attachment);
attachment->SetMimeTypeL(*paramMimeType);
TParse fileNameParser;
User::LeaveIfError(fileNameParser.Set(*paramFilePath, NULL, NULL));
attachment->SetAttachmentNameL(fileNameParser.NameAndExt());
MMsvAttachmentManager& manager = paramStore->AttachmentManagerL();
manager.AddLinkedAttachmentL(*paramFilePath, attachment, waiter->iStatus);
CleanupStack::Pop(attachment); // ownership passed to manager
waiter->StartAndWait();
User::LeaveIfError(waiter->Result());
CleanupStack::PopAndDestroy(waiter);
TMsvAttachmentId attachmentId = attachment->Id();
paramStore->CommitL();
StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(3));
}
示例4: qDebug
//---------------------------------------------------------------
// CNativeMmsUtility::getSmilFileL
// @see header
//---------------------------------------------------------------
const QString CNativeMmsUtility::getSmilFileL()
{
#ifdef _DEBUG_TRACES_
qDebug() << " Enter CNativeMmsUtility::getSmilFileL";
#endif
TUint count = iattachmanager->AttachmentCount();
for (int i = 0; i < count; i++)
{
CMsvAttachment *attachment = iattachmanager->GetAttachmentInfoL(i);
if (attachment->MimeType().CompareF(KMsgMimeSmil) == 0)
{
#ifdef _DEBUG_TRACES_
qDebug() << " Exit CNativeMmsUtility::getSmilFileL";
#endif
return XQConversions::s60DescToQString(attachment->FilePath());
}
}
#ifdef _DEBUG_TRACES_
qDebug() << " Exit CNativeMmsUtility::getSmilFileL";
#endif
return QString();
}
示例5: fileSize
// ----------------------------------------------------------------------------
// CIpsPlgNewChildPartFromFileOperation::InitAttachmentManagerL
// ----------------------------------------------------------------------------
//
void CIpsPlgNewChildPartFromFileOperation::InitAttachmentManagerL()
{
iEntry = NULL;
iMessage = NULL;
RFile file;
TInt fileSize( 0 );
// Read attachment size
User::LeaveIfError(
file.Open( iMsvSession.FileSession(), iFilePath->Des(), EFileShareReadersOnly )
);
//in rare case that file has disappeared while sending
//we just won't get the size for it
file.Size( fileSize );
file.Close();
// Initialize CMsvAttachment instance for the attachment creation
CMsvAttachment* info = CMsvAttachment::NewL( CMsvAttachment::EMsvFile );
CleanupStack::PushL( info );
info->SetAttachmentNameL( iFilePath->Des() );
info->SetSize( fileSize );
// Create/acquire Symbian message entry objects
GetMessageEntryL( iMessageId.Id(), iEntry, iMessage );
// Start attachment creation
iMessage->AttachmentManager().AddAttachmentL(
iFilePath->Des(), info, iStatus );
CleanupStack::Pop( info ); // attachment manager takes ownership
iStep = EPrepareMsvEntry; // Next step
SetActive();
}
示例6: RunTestL
void CMtfTestActionSmtpAddLinkedAttachment::RunTestL()
{
CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
TMsvId messageEntry = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
HBufC* paramFilePath = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(2));
HBufC8* paramMimeType = ObtainParameterReferenceL<HBufC8>(TestCase(),ActionParameters().Parameter(3));
CMsvEntry* entry = paramSession->GetEntryL(messageEntry);
CleanupStack::PushL(entry);
CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry);
CleanupStack::PushL(emailMsg);
CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
CleanupStack::PushL(waiter);
CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
CleanupStack::PushL(attachment);
attachment->SetMimeTypeL(*paramMimeType);
TParse fileNameParser;
User::LeaveIfError(fileNameParser.Set(*paramFilePath, NULL, NULL));
attachment->SetAttachmentNameL(fileNameParser.NameAndExt());
TEntry fileEntry;
User::LeaveIfError(paramSession->FileSession().Entry( fileNameParser.FullName(), fileEntry));
attachment->SetSize(fileEntry.iSize);
MMsvAttachmentManager& manager = emailMsg->AttachmentManager();
manager.AddLinkedAttachmentL(*paramFilePath, attachment, waiter->iStatus);
CleanupStack::Pop(attachment); // ownership passed to manager
waiter->StartAndWait();
User::LeaveIfError(waiter->Result());
CleanupStack::PopAndDestroy(waiter);
attachment = NULL;
TInt attachmentCount = manager.AttachmentCount();
attachment = manager.GetAttachmentInfoL(attachmentCount - 1);
CleanupStack::PushL(attachment);
TMsvAttachmentId attachmentId = attachment->Id();
CleanupStack::PopAndDestroy(attachment);
CleanupStack::PopAndDestroy(2, entry); // emailMsg, entry
StoreParameterL<TMsvAttachmentId>(TestCase(),attachmentId,ActionParameters().Parameter(4));
}
示例7: 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
}
示例8: GetAttachmentSizeL
TInt32 CSmtpClientMtm::GetAttachmentSizeL(CImEmailMessage& aMessage, TMsvId aMsvId)
{
// Calculate the total size of all attachments associated with this message
TInt total=0;
aMessage.GetAttachmentsListL(iWait->iStatus, aMsvId, CImEmailMessage::EAllAttachments,CImEmailMessage::EThisMessageOnly);
iWait->Start(); // wait for the asynch operation to complete
TInt numAttachments=aMessage.AttachmentManager().AttachmentCount();
for (TInt n=0 ; n<numAttachments ; ++n)
{
CMsvAttachment* attachment = aMessage.AttachmentManager().GetAttachmentInfoL(n);
total+=attachment->Size();
delete attachment;
}
return total;
}
示例9: TestCase
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);
}
示例10: __ASSERT_DEBUG
EXPORT_C void CSmtpClientMtm::AddLinkedAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
{
__ASSERT_DEBUG(iMsvEntry->Entry().iType.iUid==KUidMsvMessageEntryValue, gPanic(ESmtcMTMNotAMessageEntry));
if( iAttachmentWaiter == NULL )
{
iAttachmentWaiter = CImAttachmentWaiter::NewL();
}
if (iEmailMessage == NULL)
{
iEmailMessage = CImEmailMessage::NewL(*iMsvEntry);
}
else if (iEmailMessage->EmailEntryId() != iMsvEntry->EntryId())
{
delete iEmailMessage;
iEmailMessage = NULL;
iEmailMessage = CImEmailMessage::NewL(*iMsvEntry);
}
CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvLinkedFile);
CleanupStack::PushL(attachmentInfo);
attachmentInfo->SetMimeTypeL(aMimeType);
TParse fileNameParser;
User::LeaveIfError(fileNameParser.Set(aFilePath, NULL, NULL));
attachmentInfo->SetAttachmentNameL(fileNameParser.NameAndExt());
if( aCharset!=0 )
{
CMsvMimeHeaders* headers = CMsvMimeHeaders::NewLC();
headers->SetMimeCharset(aCharset);
headers->StoreL(*attachmentInfo);
CleanupStack::PopAndDestroy(headers);
}
iEmailMessage->AttachmentManager().AddLinkedAttachmentL(aFilePath, attachmentInfo, iAttachmentWaiter->iStatus);
CleanupStack::Pop(attachmentInfo);// ownership passed to attachment manager
iAttachmentWaiter->StartWaitingL(aStatus, iEmailMessage, EFalse);
}
示例11: RunTestL
void CMtfTestActionSmtpRemoveEntryAttachmentById::RunTestL()
{
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);
CImEmailMessage* emailMsg = CImEmailMessage::NewL(*entry);
CleanupStack::PushL(emailMsg);
MMsvAttachmentManager& manager = emailMsg->AttachmentManager();
CMsvAttachment* attachInfo = manager.GetAttachmentInfoL(attachId);
CleanupStack::PushL(attachInfo);
// First ensure that the attachment is a file attachment
if( attachInfo->Type() != CMsvAttachment::EMsvMessageEntry )
{
User::Leave(KErrGeneral);
}
// Get the linked file
TMsvId msgId = attachInfo->EntryAttachmentId();
CleanupStack::PopAndDestroy(attachInfo);
// Remove the attachment
CMtfAsyncWaiter* waiter = CMtfAsyncWaiter::NewL();
CleanupStack::PushL(waiter);
manager.RemoveAttachmentL(attachId, waiter->iStatus);
waiter->StartAndWait();
User::LeaveIfError(waiter->Result());
CleanupStack::PopAndDestroy(waiter);
CleanupStack::PopAndDestroy(2, entry); // email msg, entry
// Ensure that the message entry still exists
CMsvEntry* checkEntry = paramSession->GetEntryL(msgId);
delete checkEntry;
checkEntry = NULL;
}
示例12: ImportFromAttachmentL
/**
Imports the Obex header list from the attachment. The header list is retrieved and
stored in this object. Any existing header data is over-written with the headers from
the attachment. If the headers have not been set, this obex list will still be
over written and result in zero headers.
@param aAttachment The attachment to retieve the header list from.
@leave System-wide error codes.
*/
EXPORT_C void CObexHeaderList::ImportFromAttachmentL(CMsvAttachment& aAttachment)
{
TPtrC8 headerData;
if( aAttachment.GetDesC8Attribute(KUidObexHeaders, headerData) == KErrNone )
{
// header data exists, attempt to import it
RDesReadStream readStream(headerData);
readStream.PushL();
readStream >> *this;
CleanupStack::PopAndDestroy(&readStream);
}
示例13: TestCase
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);
}
示例14: 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));
}
示例15: ExportToAttachmentL
/**
Exports the Obex header list to the attachment. The header list is then stored with
the attachment.
@param aAttachment The attachment to store the header list for.
@leave System-wide error codes.
*/
EXPORT_C void CObexHeaderList::ExportToAttachmentL(CMsvAttachment& aAttachment) const
{
// create a buffer stream to hold the header data
CBufFlat* obexHdrBuf = CBufFlat::NewL(KObexHeaderListSegmentSize);
CleanupStack::PushL(obexHdrBuf);
// externalise the header list to the buffer
RBufWriteStream writeStream(*obexHdrBuf);
writeStream.PushL();
writeStream << *this;
writeStream.CommitL();
CleanupStack::PopAndDestroy(&writeStream);
// set the headers in the attachment
aAttachment.SetDesC8AttributeL(KUidObexHeaders, obexHdrBuf->Ptr(0));
CleanupStack::PopAndDestroy(obexHdrBuf);
}