本文整理汇总了C++中CMsvEntry::CreateL方法的典型用法代码示例。如果您正苦于以下问题:C++ CMsvEntry::CreateL方法的具体用法?C++ CMsvEntry::CreateL怎么用?C++ CMsvEntry::CreateL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMsvEntry
的用法示例。
在下文中一共展示了CMsvEntry::CreateL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteActionL
void CMtfTestActionCreateEntry::ExecuteActionL()
{
TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionCreateEntry);
CActiveScheduler::Add(this);
iBlank = KNullDesC().AllocL();
CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
TUid paramEntryTypeUid = ObtainValueParameterL<TUid>(TestCase(),ActionParameters().Parameter(1));
TMsvId paramParentId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2));
TUid paramMtmUid = ObtainValueParameterL<TUid>(TestCase(),ActionParameters().Parameter(3), KUidMsvLocalServiceMtm);
TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(4), KMsvLocalServiceIndexEntryId);
TMsvPriority paramPriority = ObtainValueParameterL<TMsvPriority>(TestCase(),ActionParameters().Parameter(5),EMsvMediumPriority);
TInt paramReadOnlyFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(6),EFalse);
TInt paramVisibleFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(7),ETrue);
HBufC* paramDescription = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(8),iBlank);
HBufC* paramDetails = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(9),iBlank);
iIndexEntry.iType = paramEntryTypeUid;
iIndexEntry.iMtm = paramMtmUid;
iIndexEntry.iServiceId = paramServiceId;
iIndexEntry.SetPriority(paramPriority);
iIndexEntry.SetReadOnly(paramReadOnlyFlag);
iIndexEntry.SetVisible(paramVisibleFlag);
iIndexEntry.iDescription.Set(paramDescription->Des());
iIndexEntry.iDetails.Set(paramDetails->Des());
iIndexEntry.iDate.HomeTime();
CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramParentId,TMsvSelectionOrdering());
CleanupStack::PushL(entry);
entry->SetEntryL(paramParentId);
if (entry->OwningService() == KMsvLocalServiceIndexEntryId)
{
entry->CreateL(iIndexEntry);
CleanupStack::PopAndDestroy(entry);
TMsvId paramEntryId;
paramEntryId = iIndexEntry.Id();
StoreParameterL<TMsvId>(TestCase(),paramEntryId,ActionParameters().Parameter(10));
TestCase().ActionCompletedL(*this);
}
else
{
iOperation = entry->CreateL(iIndexEntry,iStatus);
SetActive();
}
TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionCreateEntry);
}
示例2: CreateServiceL
/**
Creates a New Service
If a Service Exists it doesnot create a new one
@param aSession Current Session reference
@param aDescription Entry Description Descriptor
@param aDetail Entry Details Descriptor
@internalTechnology
*/
void CentralRepoUtils::CreateServiceL(CMsvSession* aSession, const TDesC& aDescription, const TDesC& aDetail)
{
TMsvId serviceId=0;
TRAPD(err,TSmsUtilities::ServiceIdL(*aSession,serviceId));
if(err == KErrNotFound) // If Service Already Exists Do not create new One
{
TInt priority = EMsvMediumPriority;
TInt readOnlyFlag = EFalse;
TInt visibleFlag = ETrue;
TMsvEntry indexEntry;
indexEntry.iType = KUidMsvServiceEntry;
indexEntry.iMtm = KUidMsgTypeSMS;
indexEntry.SetReadOnly(readOnlyFlag);
indexEntry.SetVisible(visibleFlag);
indexEntry.SetPriority(TMsvPriority(priority));
indexEntry.iDescription.Set(aDescription);
indexEntry.iDetails.Set(aDetail);
indexEntry.iDate.HomeTime();
CMsvEntry* entry = CMsvEntry::NewL(*aSession,KMsvRootIndexEntryId,TMsvSelectionOrdering());
CleanupStack::PushL(entry);
entry->CreateL(indexEntry);
CleanupStack::PopAndDestroy(entry);
}
}
示例3: TestIncPcSyncCountL
void CT_CMsvSession::TestIncPcSyncCountL()
{
TInt error = KErrGeneral;
INFO_PRINTF1(_L("Testing: Increment PC Sync Count -- started"));
TRAP(error, iSession = CMsvSession::OpenSyncL(*this));
TEST(error == KErrNone);
CMsvOperationWait* active = CMsvOperationWait::NewLC();
CMsvEntry* cEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
CleanupStack::PushL(cEntry);
CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
CleanupStack::PushL(selection);
TInt ret = iSession->InstallMtmGroup(KDataComponentFilename);
TEST(ret==KErrNone|| ret==KErrAlreadyExists);
cEntry->SetEntryL(KMsvRootIndexEntryId);
TMsvEntry service;
service.iType=KUidMsvServiceEntry;
service.iMtm = KUidTestServerMtmType;
cEntry->CreateL(service);
selection->AppendL(service.Id());
TBuf8<256> progress;
TBuf8<32> param;
TRAP(error, iSession->IncPcSyncCountL(*selection);)
示例4: CreateNewMessageL
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CSMSSender::CreateNewMessageL()
{
Cancel();
iMessageMade = iMessageSent = iMessageReceived = EFalse;
delete iMtm;
iMtm = NULL;
TMsvEntry newEntry; // This represents an entry in the Message Server index
newEntry.iMtm = KUidMsgTypeSMS; // message type is SMS
newEntry.iType = KUidMsvMessageEntry; // this defines the type of the entry: message
newEntry.iServiceId = KMsvLocalServiceIndexEntryId; // ID of local service (containing the standard folders)
newEntry.iDate.UniversalTime(); // set the date of the entry to home time
newEntry.SetInPreparation(ETrue); // a flag that this message is in preparation
newEntry.SetReadOnly(EFalse);
// - CMsvEntry accesses and acts upon a particular Message Server entry.
// - NewL() does not create a new entry, but simply a new object to access an existing entry.
// - It takes in as parameters the client's message server session,
// ID of the entry to access and initial sorting order of the children of the entry.
CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvDraftEntryIdValue, TMsvSelectionOrdering());
CleanupStack::PushL(entry);
delete iOperation;
iOperation = NULL;
iOperation = entry->CreateL(newEntry, iStatus);
CleanupStack::PopAndDestroy(entry);
iPhase = EWaitingForCreate;
SetActive();
}
示例5: CreateNewMessageL
TMsvId CFakeSMSSender::CreateNewMessageL(TTime aMsgTime)
{
CMsvEntry* Draftentry = CMsvEntry::NewL(*iMsvSession, KMsvDraftEntryIdValue ,TMsvSelectionOrdering());
CleanupStack::PushL(Draftentry);
CMsvOperationWait* wait = CMsvOperationWait::NewLC();
wait->Start();
TMsvEntry newEntry; // This represents an entry in the Message Server index
newEntry.iMtm = KUidMsgTypeSMS; // message type is SMS
newEntry.iType = KUidMsvMessageEntry; //KUidMsvServiceEntry // this defines the type of the entry: message
newEntry.iServiceId = KMsvLocalServiceIndexEntryId; // // ID of local service (containing the standard folders)
newEntry.iDate = aMsgTime; // set the date of the entry to home time
newEntry.SetInPreparation(ETrue); // a flag that this message is in preparation
newEntry.SetReadOnly(EFalse);
CMsvOperation* oper = Draftentry->CreateL(newEntry,wait->iStatus);
CleanupStack::PushL(oper);
CActiveScheduler::Start();
while( wait->iStatus.Int() == KRequestPending )
{
CActiveScheduler::Start();
}
// ...and keep track of the progress of the create operation.
TMsvLocalOperationProgress progress = McliUtils::GetLocalProgressL(*oper);
User::LeaveIfError(progress.iError);
// Draftentry->MoveL(progress.iId,KMsvGlobalInBoxIndexEntryId);
CleanupStack::PopAndDestroy(3);//Draftentry,wait,oper
return progress.iId;
}
示例6: 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);
}
示例7: 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" ) );
}
示例8: TestSetSendingStateAttributeL
LOCAL_C void TestSetSendingStateAttributeL()
{
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);
CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
CleanupStack::PushL(selection);
TMsvEntry entry1;
entry1.iType = KUidMsvMessageEntry;
entry1.iMtm = KUidMsvLocalServiceMtm;
entry1.iServiceId = KMsvLocalServiceIndexEntryId;
entry1.SetSendingState(12);
cEntry->CreateL(entry1);
selection->AppendL(entry1.Id());
TMsvEntry entry2;
entry2.iType = KUidMsvMessageEntry;
entry2.iMtm = KUidMsvLocalServiceMtm;
entry2.iServiceId = KMsvLocalServiceIndexEntryId;
entry2.SetSendingState(3);
cEntry->CreateL(entry2);
selection->AppendL(entry2.Id());
session->ChangeAttributesL(*selection, 6<<KMsvSendingStateShift, 0);
cEntry->SetEntryL(entry1.Id());
test(cEntry->Entry().SendingState() == 6);
cEntry->SetEntryL(entry2.Id());
test(cEntry->Entry().SendingState() == 6);
CleanupStack::PopAndDestroy(4); // selection, cEntry, session, ob
}
示例9: 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
}
示例10: AddUserFolderL
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::AddUserFolderL
// Creates new user folder
// -----------------------------------------------------------------------------
TInt CMmsAdapterMsvApi::AddUserFolderL( TMsvId& aFolder, const TDesC& aName )
{
TRACE_FUNC_ENTRY;
LOGGER_WRITE_1( "aName: %S", &aName );
// Make sure that we are not going to add same folder twise
TBool found( EFalse );
found = FindUserFolderL( aName, aFolder );
if ( found )
{
LOGGER_WRITE( "Folder already exists" );
LOGGER_LEAVEFN( "CMmsAdapterMsvApi::AddUserFolderL" );
return KErrNone;
}
CMsvEntry* entry = iSession.GetEntryL(KMsvMyFoldersEntryIdValue);
CleanupStack::PushL( entry );
TTime date;
date.UniversalTime();
TMsvEntry folderEntry;
folderEntry.iType = KUidMsvFolderEntry;
folderEntry.iMtm = KUidMsvLocalServiceMtm;
folderEntry.iDetails.Set( aName );
folderEntry.iServiceId = KMsvLocalServiceIndexEntryIdValue;
folderEntry.iSize = sizeof( folderEntry );
folderEntry.iDate = date;
folderEntry.SetStandardFolder( EFalse );
folderEntry.SetVisible( ETrue );
folderEntry.SetComplete( ETrue );
folderEntry.SetInPreparation( EFalse );
folderEntry.SetReadOnly( EFalse );
entry->CreateL( folderEntry );
CleanupStack::PopAndDestroy( entry );
aFolder = folderEntry.Id();
TRACE_FUNC_EXIT;
return KErrNone;
}
示例11: TestTransferCommandL
void CT_CMsvSession::TestTransferCommandL()
{
TInt error = KErrGeneral;
INFO_PRINTF1(_L("Testing: Transfer Commands -- started"));
TRAP(error, iSession = CMsvSession::OpenSyncL(*this));
TEST(error == KErrNone);
CMsvOperationWait* active = CMsvOperationWait::NewLC();
CMsvEntry* cEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
CleanupStack::PushL(cEntry);
CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
CleanupStack::PushL(selection);
TInt ret = iSession->InstallMtmGroup(KDataComponentFilename);
TEST(ret==KErrNone|| ret==KErrAlreadyExists);
cEntry->SetEntryL(KMsvRootIndexEntryId);
TMsvEntry service;
service.iType=KUidMsvServiceEntry;
service.iMtm = KUidTestServerMtmType;
cEntry->CreateL(service);
selection->AppendL(service.Id());
TBuf8<256> progress;
TBuf8<32> param;
CMsvOperation* operation = NULL;
active->Start();
operation = iSession->TransferCommandL(*selection, 1, param, active->iStatus);
CActiveScheduler::Start();
TEST(operation->iStatus.Int()==KErrNone);
cEntry->DeleteL(service.Id());
delete operation;
CleanupStack::PopAndDestroy(selection);
CleanupStack::PopAndDestroy(cEntry);
CleanupStack::PopAndDestroy(active);
delete iSession;
INFO_PRINTF1(_L("Testing: Transfer Commands -- ended"));
}
示例12: CreateEntry
LOCAL_C void CreateEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry, TInt aError, CEntryObserver& aObserver)
{
CTestActive* active = new (ELeave) CTestActive;
CleanupStack::PushL(active);
active->StartL();
aObserver.Start();
CMsvOperation* opert = aClientEntry.CreateL(aNewEntry, active->iStatus);
CActiveScheduler::Start(); // operation complete
CActiveScheduler::Start(); // cEntry changed
test(opert->iStatus.Int()==KErrNone);
test(opert->Mtm()==KUidMsvLocalServiceMtm);
test(opert->Service()==KMsvLocalServiceIndexEntryId);
TMsvLocalOperationProgress details;
TPckgC<TMsvLocalOperationProgress> package(details);
package.Set(opert->ProgressL());
test(package().iType==TMsvLocalOperationProgress::ELocalNew);
test(package().iTotalNumberOfEntries==1);
test(package().iError==aError);
if (aError)
{
test(package().iNumberCompleted==0);
test(package().iNumberFailed==1);
}
else
{
test(package().iNumberCompleted==1);
test(package().iNumberFailed==0);
TTestMsvEntry* ptr = (TTestMsvEntry*)&aNewEntry;
ptr->SetId(package().iId);
ptr->SetParent(aClientEntry.EntryId());
if (aNewEntry.iType==KUidMsvServiceEntry)
aNewEntry.iServiceId = aNewEntry.Id();
}
test(package().iNumberRemaining==0);
delete opert;
opert=NULL;
CleanupStack::PopAndDestroy(); // active
}
示例13: TestCleanupStackL
LOCAL_C void TestCleanupStackL()
{
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);
TMsvEntry entry;
entry.iType = KUidMsvMessageEntry;
entry.iMtm = KUidMsvLocalServiceMtm;
entry.iServiceId = KMsvLocalServiceIndexEntryId;
// Create an entry
cEntry->CreateL(entry);
// Make sure heap failure occurs in CleanupEntryPushL
// If a failure occurs the entry should still be on cleanup stack
__UHEAP_FAILNEXT(0);
TRAPD(error, session->CleanupEntryPushL(entry.Id()); session->CleanupEntryPop(); );
示例14: createMMS
//---------------------------------------------------------------
// TestUniDataModelPlugin::createMMS
//---------------------------------------------------------------
void TestUniDataModelMMSPlugin::createMMS(TMsvId pId, TBool subjectField)
{
TMsvEntry indexEntry;
indexEntry.iType = KUidMsvMessageEntry;
indexEntry.iMtm = KUidMsgTypeMultimedia;
indexEntry.iServiceId = iServiceId;
indexEntry.iDate.HomeTime();
// Convert TTime to QDateTime , this will be used for comparing the time of mesage
// when fetched from datamodel
TTime unixEpoch(KUnixEpoch);
TTimeIntervalSeconds seconds;
TTime timeStamp = indexEntry.iDate;
timeStamp.SecondsFrom(unixEpoch, seconds);
retTimeStamp.setTime_t(seconds.Int());
TMsvId parentId = pId;
CMsvEntry* entry = CMsvEntry::NewL(*iMSession,parentId,TMsvSelectionOrdering());
CleanupStack::PushL(entry);
entry->SetEntryL(parentId);
entry->CreateL(indexEntry);
entry->SetEntryL(indexEntry.Id());
iMmsClientMtm->SwitchCurrentEntryL(entry->EntryId());
CMsvStore* store = iMmsClientMtm->Entry().EditStoreL();
CleanupStack::PushL(store);
//MMS Message ID Saved
iMessageId = indexEntry.Id();
//Adding Subject
if(subjectField)
{
QString subject(TEST_MSG_SUBJECT);
HBufC* subj = XQConversions::qStringToS60Desc(subject);
iMmsClientMtm->SetSubjectL(*subj);
}
//Adding Sender
QString sender(TEST_MSG_FROM1);
HBufC* addr = XQConversions::qStringToS60Desc(sender);
if (addr)
{
CleanupStack::PushL(addr);
TBuf<32> name;
name.Copy(addr->Left(32));
indexEntry.iDetails.Set(name);
iMmsClientMtm->SetSenderL(*addr);
CleanupStack::PopAndDestroy(addr);
}
//Adding Recipient
QString recipient(TEST_MSG_RECIEPIENT1);
HBufC* addr2 = XQConversions::qStringToS60Desc(recipient);
if (addr2)
{
CleanupStack::PushL(addr2);
iMmsClientMtm->AddAddresseeL(EMsvRecipientTo,*addr2);
CleanupStack::PopAndDestroy(addr2);
}
//Adding cCRecipient
QString recipient2(TEST_MSG_RECIEPIENT2);
HBufC* addr3 = XQConversions::qStringToS60Desc(recipient2);
if (addr3)
{
CleanupStack::PushL(addr3);
iMmsClientMtm->AddAddresseeL(EMsvRecipientCc,*addr3);
CleanupStack::PopAndDestroy(addr3);
}
//Adding bCCRecipient
QString recipient3(TEST_MSG_RECIEPIENT3);
HBufC* addr4 = XQConversions::qStringToS60Desc(recipient3);
if (addr4)
{
CleanupStack::PushL(addr4);
iMmsClientMtm->AddAddresseeL(EMsvRecipientBcc,*addr4);
CleanupStack::PopAndDestroy(addr4);
}
//Create Text Attachment
TMsvAttachmentId attaId = 0;
TFileName attachmentFile( _L("story.txt") );
TBufC<12> story = _L( "Hello world!" );
iMmsClientMtm->CreateTextAttachmentL(*store, attaId, story, attachmentFile, ETrue );
qDebug() << "Text Attachment id" << attaId;
//Image Attachment added to the message entry
RFile attaFile;
// Set filename of attachment
TFileName name( KPictureFileName );
//.........这里部分代码省略.........
示例15: send_messageL
void CSmsFile::send_messageL(const TDesC& recipient, const TDesC& body)
{
if (iStatus==KRequestPending) {
User::Leave(KErrServerBusy);
}
state=_L("send_messageL");
TMsvEntry newEntry; // This represents an entry in the Message Server index
newEntry.iMtm = KUidMsgTypeSMS; // message type is CSmsFile
newEntry.iType = KUidMsvMessageEntry; // this defines the type of the entry: message
newEntry.iServiceId = KMsvLocalServiceIndexEntryId; // ID of local service (containing the standard folders)
newEntry.iDate.HomeTime(); // set the date of the entry to home time
newEntry.SetInPreparation(ETrue); // a flag that this message is in preparation
// get ref to outbox
state=_L("NewL");
CMsvEntry *entry =CMsvEntry::NewL(*iSession, KMsvGlobalOutBoxIndexEntryId ,TMsvSelectionOrdering());
CleanupStack::PushL(entry);
// create message in outbox
state=_L("CreateL");
entry->CreateL(newEntry);
state=_L("GetEntry");
entry = iSession->GetEntryL(newEntry.Id());
// SetCurrentEntryL takes ownership of the CMsvEntry
state=_L("SetCurrentEntry");
iMtm->SetCurrentEntryL(entry);
CleanupStack::Pop(); // entry
state=_L("Entry()");
TMsvEntry msvEntry = (iMtm->Entry()).Entry();
state=_L("Body()");
CRichText& mtmBody = iMtm->Body();
mtmBody.Reset();
state=_L("set message");
mtmBody.InsertL(0, body); // insert our msg tag as the body text
// set iRecipient into the Details of the entry
msvEntry.iDetails.Set(recipient); // set recipient info in details
msvEntry.SetInPreparation(EFalse); // set inPreparation to false
msvEntry.SetSendingState(KMsvSendStateWaiting); // set the sending state (immediately)
msvEntry.iDate.HomeTime(); // set time to Home Time
// To handle the CSmsFile specifics we start using SmsMtm
CSmsClientMtm* smsMtm = STATIC_CAST(CSmsClientMtm*, iMtm);
state=_L("RestoreServiceAndSettingsL");
smsMtm->RestoreServiceAndSettingsL();
state=_L("set header");
// CSmsHeader encapsulates data specific for CSmsFile messages,
// like service center number and options for sending.
CSmsHeader& header = smsMtm->SmsHeader();
state=_L("get options");
if (!sendOptions) {
sendOptions = CSmsSettings::NewL();
sendOptions->CopyL(smsMtm->ServiceSettings()); // restore existing settings
state=_L("SetDelivery");
sendOptions->SetDelivery(ESmsDeliveryImmediately); // set to be delivered immediately
}
// set send options
// ERROR HERE!
state=_L("SetSmsSettingsL");
header.SetSmsSettingsL(*sendOptions);
state=_L("check sc");
// let's check if there's sc address
if (header.Message().ServiceCenterAddress().Length() == 0)
{
// no, there isn't. We assume there is at least one sc number set and use
// the default SC number.
CSmsSettings* serviceSettings = &(smsMtm->ServiceSettings());
// if number of scaddresses in the list is null
if (!serviceSettings->NumSCAddresses())
{
// FIXME: what to do?
User::Leave(1);
} else {
// set sc address to default.
CSmsNumber* sc = 0;
sc = &(serviceSettings->SCAddress(serviceSettings->DefaultSC()));
header.Message().SetServiceCenterAddressL(sc->Address());
}
}
state=_L("add addresses");
// Add our recipient to the list, takes in two TDesCs, first is real address and second is an alias
// works also without the alias parameter.
//.........这里部分代码省略.........