// ---------------------------------------------------------------------------- // CIpsPlgPop3ConnectOp::ConstructL() // ---------------------------------------------------------------------------- // void CIpsPlgPop3ConnectOp::ConstructL() { FUNC_LOG; BaseConstructL( KUidMsgTypePOP3 ); // <qmail> iSelection construction has been removed CMsvEntry* cEntry = iMsvSession.GetEntryL( iService ); User::LeaveIfNull( cEntry ); // NOTE: Not using cleanupStack as it is not needed in this situation: const TMsvEntry tentry = cEntry->Entry(); delete cEntry; cEntry = NULL; if ( tentry.iType.iUid != KUidMsvServiceEntryValue ) { // should we panic with own codes? User::Leave( KErrNotSupported ); } // <qmail> no need to have population limit as member variable // <qmail> it is read from settings when needed if ( tentry.Connected() ) { iState = EConnected; // <qmail> iAlreadyConnected removed } else { iState = EStartConnect; } // <qmail> SetActive(); moved inside CompleteThis(); CompleteThis(); }
/* ----------------------------------------------------------------------------- ---------------------------------------------------------------------------- */ void CMailBoxContainer::AddEmailFoldersL(CMsvSession* aSession) { if(aSession) { CMsvEntry *localServiceEntry = aSession->GetEntryL(KMsvRootIndexEntryId);//KMsvLocalServiceIndexEntryId); CleanupStack::PushL(localServiceEntry); CMsvEntrySelection *folders = localServiceEntry->ChildrenL(); CleanupStack::PushL(folders); if(folders->Count() > 1) // first is local folder { for (TInt i = 1;i < folders->Count();i++) { TMsvEntry ExtraFolder = localServiceEntry->ChildDataL((*folders)[i]); CMailFldItem* NewIttem = new(ELeave)CMailFldItem(); CleanupStack::PushL(NewIttem); NewIttem->iTitle = ExtraFolder.iDetails.AllocL(); NewIttem->iMscId = ExtraFolder.Id(); CleanupStack::Pop();//NewIttem iFolderArray.Append(NewIttem); } } CleanupStack::PopAndDestroy(2); // localServiceEntry, folders } }
TInt CIacSettingsParser::CompleteMessage() { TMsvEntry entry = iEntry.Entry(); entry.SetMtmData3(KBIO_MSG_ENTRY_PROCESSED); TRAPD(error, iEntry.ChangeL(entry)); return error; }
// methods from CSendAsEditUtils void CSendAsTestEditUtils::LaunchEditorL(TMsvId /*aId*/, TRequestStatus& aStatus) { CDummyObserver* ob1 = new(ELeave) CDummyObserver; CleanupStack::PushL(ob1); CMsvSession* session = CMsvSession::OpenSyncL(*ob1); CleanupStack::PushL(session); CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue)); CleanupStack::PushL(cEntry); CMsvEntrySelection* selection = cEntry->ChildrenL(); CleanupStack::PushL(selection); CMsvEntry* cEntry2 = session->GetEntryL(selection->At(0)); CleanupStack::PushL(cEntry2); TMsvEntry entry = cEntry2->Entry(); entry.SetMtmData3(234567890); // Show we've been called by touching the TMsvEntry. cEntry2->ChangeL(entry); CleanupStack::PopAndDestroy(5, ob1); // cEntry2, selection, cEntry, session, ob1 iUserStatus = &aStatus; aStatus = KRequestPending; // wait a few seconds before completing iEditTimer->After(KSendAsTestEditWaitTime); }
LOCAL_C void InitL() { // Connect to the file system... gFs.Connect(); // Connect to the Message Server... pObserver = new (ELeave) CObserver(); CleanupStack::PushL(pObserver); pSession = CMsvSession::OpenSyncL(*pObserver); CleanupStack::PushL(pSession); // Create a test entry with some dummy values so the Message Server // will not panic when the entry is created in the message store... pContext = CMsvEntry::NewL(*pSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering()); CleanupStack::PushL(pContext); TMsvEntry testEntry; TUid entryMtm; entryMtm.iUid = 11; testEntry.iMtm = entryMtm; testEntry.iServiceId = pContext->OwningService(); testEntry.iType = KUidMsvMessageEntry; // Create the entry in the message store and set the current context to it... pContext->CreateL(testEntry); gTestEntryId = testEntry.Id(); pContext->SetEntryL(gTestEntryId); }
/** Creates a new entry as a child of the current context. Ownership of the created entry is given to the process with the specified SID. The parent ID and entry ID are set by the Message Server. @param aEntry Index entry value for the new entry @param aOwnerId The SID of the process that will own the create entry. @param aBulk A boolean value to indicate whether this is part of a bulk operation. (ETrue = bulk) @return KErrNone - success; KErrNoMemory - a memory allocation failed; KErrNotSupported - aEntry is invalid */ EXPORT_C TInt CMsvServerEntry::CreateEntry(TMsvEntry& aEntry, TSecureId aOwnerId, TBool aBulk) { __ASSERT_DEBUG(iEntry.Id()!=KMsvNullIndexEntryId, PanicServer(EMsvEntryWithNoContext2)); aEntry.SetParent(iEntry.Id()); __ASSERT_DEBUG(MsvUtils::ValidEntry(aEntry, ETrue), PanicServer(EMsvBadEntryContents)); // if valid - try to create the new child TInt error; if (iEntry.Id()==KMsvNullIndexEntryId || !MsvUtils::ValidEntry(aEntry, ETrue)) error = KErrNotSupported; else { error = iServer.AddEntry(aEntry, aOwnerId, ETrue, aBulk); // if the child was created,then notify everyone, otherwise reset the parent if (error) aEntry.SetParent(KMsvNullIndexEntryId); else { if (!aBulk) { iServer.NotifyChanged(EMsvEntriesCreated, aEntry.Id(), aEntry.Parent()); } iEntry.SetOwner(ETrue); } } return error; }
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);)
// ----------------------------------------------------------------------------- // CMmsAdapterMsvApi::FindUserFolderL // ----------------------------------------------------------------------------- // TBool CMmsAdapterMsvApi::FindUserFolderL( const TDesC& aName, TMsvId& aFolder ) { CMsvEntry* entry = iSession.GetEntryL( KMsvMyFoldersEntryIdValue ); CleanupStack::PushL( entry ); CMsvEntrySelection* selection = entry->ChildrenL(); CleanupStack::PushL( selection ); TBool found( EFalse ); TMsvId serviceId; TMsvEntry entryT; for ( TInt i = 0; i < selection->Count(); i++ ) { User::LeaveIfError( iSession.GetEntry( selection->At( i ), serviceId, entryT ) ); if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && aName.Compare(entryT.iDescription) == 0 ) { found = ETrue; aFolder = entryT.Id(); break; } } CleanupStack::PopAndDestroy( selection ); CleanupStack::PopAndDestroy( entry ); return found; }
/** 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); } }
// ----------------------------------------------------------------------------- // CMmsAdapterMsvApi::FindUserFolderL // ----------------------------------------------------------------------------- // TBool CMmsAdapterMsvApi::FindUserFolderL( TMsvId aFolder, TPtrC& aName, TTime& aDate ) { TBool found( EFalse ); CMsvEntry* entry = iSession.GetEntryL( KMsvMyFoldersEntryIdValue ); CleanupStack::PushL( entry ); CMsvEntrySelection* selection = entry->ChildrenL(); CleanupStack::PushL( selection ); TMsvId serviceId; TMsvEntry entryT; for ( TInt i = 0; i < selection->Count(); i++ ) { User::LeaveIfError( iSession.GetEntry( selection->At( i ), serviceId, entryT ) ); if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && entryT.Id() == aFolder ) { found = ETrue; aDate = entryT.iDate; aName.Set( entryT.iDetails ); break; } } CleanupStack::PopAndDestroy( selection ); CleanupStack::PopAndDestroy( entry ); return found; }
void CPigeonServerMtm::ConstructL() { iScheduleSend = CPigeonScheduledSend::NewL(*iServerEntry); // Get the entry id for the pigeon service entry. User::LeaveIfError(iServerEntry->SetEntry(KMsvRootIndexEntryId)); CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection(); CleanupStack::PushL(sel); User::LeaveIfError(iServerEntry->GetChildrenWithMtm(KUidMsgTypePigeon, *sel)); TInt count = sel->Count(); if( count > 1 ) // should only be one service entry User::Leave(KErrCorrupt); if( count == 0 ) { // Create the settings TMsvEntry serviceEntry; serviceEntry.iType= KUidMsvServiceEntry; serviceEntry.iMtm = KUidMsgTypePigeon; User::LeaveIfError(iServerEntry->CreateEntry(serviceEntry)); iServiceId = serviceEntry.Id(); } else { iServiceId = sel->At(0); } CleanupStack::PopAndDestroy(sel); User::LeaveIfError(iServerEntry->SetEntry(KMsvNullIndexEntryId)); iHeapFailure = EFalse; }
void CBulkCommitServerMtm::ConstructL() { // Get the entry id for the bulkcommit service entry. User::LeaveIfError(iServerEntry->SetEntry(KMsvRootIndexEntryId)); CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection(); CleanupStack::PushL(sel); User::LeaveIfError(iServerEntry->GetChildrenWithMtm(KUidBulkCommitTestMtm, *sel)); TInt count = sel->Count(); if( count > 1 ) // should only be one service entry { User::Leave(KErrCorrupt); } if( count == 0 ) { // Create the settings TMsvEntry serviceEntry; serviceEntry.iType= KUidMsvServiceEntry; serviceEntry.iMtm = KUidBulkCommitTestMtm; User::LeaveIfError(iServerEntry->CreateEntry(serviceEntry)); iServiceId = serviceEntry.Id(); } else { iServiceId = sel->At(0); } CleanupStack::PopAndDestroy(sel); }
void CPopsTestHarness::DoLocalCopyTestL() // Test copying a message locally. ie create a message in the Drafts folder // and copy it to a local sub folder { // Create the Message in the Drafts Folder iTestUtils->CreateMessageL(KTestMsgPath, KMsvDraftEntryId, KMsvDraftEntryId); CMsvServerEntry* serverEntry = iTestUtils->iServerEntry; serverEntry->SetEntry(KMsvDraftEntryId); CMsvEntrySelection* newMessageList = new (ELeave)CMsvEntrySelection(); CleanupStack::PushL(newMessageList); serverEntry->GetChildren(*newMessageList); TMsvId newMessageId = (*newMessageList)[0]; // Create a local folder under the Drafts folder TMsvEntry parentEntry = serverEntry->Entry(); TMsvEntry newFolder; newFolder.SetStandardFolder(ETrue); newFolder.iDetails.Set(KSubFolder); newFolder.iType.iUid=KUidMsvFolderEntryValue; newFolder.iMtm=parentEntry.iMtm; newFolder.iServiceId = parentEntry.iServiceId; serverEntry->CreateEntry(newFolder); // Fill the Disk Space and attempt to do the Copy FillDiskL(); // Copy the message into the new LOCAL Sub-Folder CTestActive* active = new(ELeave) CTestActive; CleanupStack::PushL(active); serverEntry->CopyEntryL(newMessageId, newFolder.Id(), active->iStatus); active->StartL(); CActiveScheduler::Start(); CleanupStack::PopAndDestroy(2); // newMessageList, active }
/* ----------------------------------------------------------------------------- ---------------------------------------------------------------------------- */ void CMailBoxContainer::GetFoldersL(void) { iFolderArray.ResetAndDestroy(); if(iSession) { CMsvEntry *localServiceEntry = iSession->GetEntryL(KMsvLocalServiceIndexEntryId); CleanupStack::PushL(localServiceEntry); CMsvEntrySelection *folders = localServiceEntry->ChildrenWithTypeL(KUidMsvFolderEntry); CleanupStack::PushL(folders); for (TInt i = 0;i < folders->Count();i++) { TMsvEntry ExtraFolder = localServiceEntry->ChildDataL((*folders)[i]); CMailFldItem* NewIttem = new(ELeave)CMailFldItem(); CleanupStack::PushL(NewIttem); NewIttem->iTitle = ExtraFolder.iDetails.AllocL(); NewIttem->iMscId = ExtraFolder.Id(); CleanupStack::Pop();//NewIttem iFolderArray.Append(NewIttem); } CleanupStack::PopAndDestroy(2); // localServiceEntry, folders AddEmailFoldersL(iSession); } }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ 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(); }
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; }
// ----------------------------------------------------------------------------- // 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" ) ); }
// ----------------------------------------------------------------------------- // CWPMessage::PostprocessEntryL // ----------------------------------------------------------------------------- // void CWPMessage::PostprocessEntryL( CMsvEntry& aCEntry, TMsvEntry& aTEntry ) { FLOG( _L( "CWPMessage::PostprocessEntryL" ) ); aTEntry.SetReadOnly(EFalse); aTEntry.SetVisible(ETrue); aTEntry.SetInPreparation(EFalse); aCEntry.ChangeL(aTEntry); }
LOCAL_C void TestNotifyBug2L() { CDummyObserver* ob = new(ELeave)CDummyObserver; CleanupStack::PushL(ob); CMsvSession* session = CMsvSession::OpenSyncL(*ob); CleanupStack::PushL(session); // Create the first CMsvEntry sitting on drafts CMsvEntry* cEntry1 = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering(0, EMsvSortByNone, ETrue)); CleanupStack::PushL(cEntry1); // Add an observer to the first CMsvEntry CEntryObserver* eOb1 = new(ELeave)CEntryObserver; CleanupStack::PushL(eOb1); cEntry1->AddObserverL(*eOb1); // Create another CMsvEntry sitting on drafts CMsvEntry* cEntry2 = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering()); CleanupStack::PushL(cEntry2); // Create an entry in drafts TMsvEntry entry; entry.iType = KUidMsvMessageEntry; entry.iMtm = KUidMsvLocalServiceMtm; entry.iServiceId = KMsvLocalServiceIndexEntryId; cEntry2->CreateL(entry); // Wait for create notification to be received by the first CMsvEntry eOb1->Start(); CActiveScheduler::Start(); // Change the entry in drafts // This queues a change notification in the server // It is waiting to be handled by all the observers cEntry2->SetEntryL(entry.Id()); cEntry2->ChangeL(entry); cEntry2->SetEntryL(KMsvDraftEntryId); // Start an asynchronous delete using the second CMsvEntry CMsvOperationWait* wait = CMsvOperationWait::NewLC(); wait->Start(); CMsvOperation* op = cEntry2->DeleteL(entry.Id(), wait->iStatus); CleanupStack::PushL(op); // The first CMsvEntry is out of date because it hasn't been told that the entry has been deleted from drafts yet // Switching the CMsvEntry in and out of drafts forces it to be up to date // But there is still a change notification waiting to be handled cEntry1->SetEntryL(KMsvRootIndexEntryId); cEntry1->SetEntryL(KMsvDraftEntryId); // The first CMsvEntry is now up to date, but in the next CActiveScheduler::Start() it receives a change notification // for a child that doesn't exist CActiveScheduler::Start(); CleanupStack::PopAndDestroy(7); // op, wait, cEntry2, eOb1, cEntry1, session, ob }
/** Utility function that updates message index entry fields to reflect the message's scheduling. @param aRef Scheduler item. @param aInfo Scheduler task information. @param aTime Schedule start time. @param aFinalState Sending state flag. @param aEntry On return, updated index entry. @param aData On return, populated messaging scheduling data. */ EXPORT_C void CMsvScheduleSend::UpdateEntryAfterSchedule(const TSchedulerItemRef& aRef, const TTaskInfo& aInfo, const TTime& aTime, TInt aFinalState, TMsvEntry& aEntry, TMsvEntryScheduleData& aData) { aEntry.SetScheduled(ETrue); aEntry.SetFailed(EFalse); aEntry.SetSendingState(aFinalState); aEntry.SetConnected(EFalse); aEntry.iDate = aTime; aData.iRef = aRef; aData.iTaskId = aInfo.iTaskId; }
void CMsvServerEntry::RunL() // // // { __ASSERT_DEBUG(iEntryState != EMsvIdle, PanicServer(EMsvServerEntryIdle)); __ASSERT_DEBUG(iCopyMove, PanicServer(EMsvCopyMoveCompletionMissing)); if (iCopyMove->CompletedIds().Count() > 0) { switch (iEntryState) { case EMsvMoving: { iServer.NotifyChanged(EMsvEntriesMoved, iCopyMove->CompletedIds(), iCopyMove->TargetId(), iEntry.Id()); TMsvEntry* pEntry; TInt err = KErrNone; err = iServer.IndexAdapter().GetEntry(iEntry.Id(), pEntry); if (err ==KErrNone) iEntry.SetOwner(pEntry->Owner()); break; } case EMsvCopying: { const CMsvEntrySelection& newEntries = static_cast<CMsvCopyEntries*>(iCopyMove)->NewEntryIds(); iServer.NotifyChanged(EMsvEntriesCreated, newEntries, iCopyMove->TargetId()); if (iCompletedSelection) { iCompletedSelection->Reset(); TInt count = newEntries.Count(); while (count--) iCompletedSelection->AppendL(newEntries[count]); } else if (iCompletedEntryId) *iCompletedEntryId = newEntries[0]; break; } default: break; } } delete iCopyMove; iCopyMove = NULL; iEntryState = EMsvIdle; User::RequestComplete(iObserverStatus, iStatus.Int()); }
// ----------------------------------------------------------------------------- // CWPMessage::StoreMsgL // ----------------------------------------------------------------------------- // void CWPMessage::StoreMsgL( TInt aResource ) { FLOG( _L( "CWPMessage::StoreMsgL(aResource)" ) ); // create an invisible blank entry TMsvEntry entry; PrepareEntryLC( entry ); // details on cleanup stack entry.iMtm = KUidMsgTypeSMS; // Store entry in inbox CMsvEntry* msvEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId); CleanupStack::PushL(msvEntry); msvEntry->CreateL(entry); msvEntry->Session().CleanupEntryPushL(entry.Id()); msvEntry->SetEntryL(entry.Id()); // Save the message body CMsvStore* store = msvEntry->EditStoreL(); CleanupStack::PushL(store); CParaFormatLayer* paraFormat = CParaFormatLayer::NewL(); CleanupStack::PushL( paraFormat ); CCharFormatLayer* charFormat = CCharFormatLayer::NewL(); CleanupStack::PushL( charFormat ); CRichText* body = CRichText::NewL( paraFormat, charFormat ); CleanupStack::PushL( body ); HBufC* text = LoadStringLC( aResource ); body->InsertL( body->DocumentLength(), *text ); store->StoreBodyTextL( *body ); // Store the actual message for post-mortem analysis iMessage->StoreL( *store ); // Save the SMS header and create a description field CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *body ); CleanupStack::PushL( header ); TBuf<KSmsDescriptionLength> description; CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL(); CleanupStack::PushL( smsPlugin ); smsPlugin->GetDescription( header->Message(), description ); CleanupStack::PopAndDestroy( smsPlugin ); entry.iDescription.Set( description ); header->StoreL( *store ); store->CommitL(); CleanupStack::PopAndDestroy( 5 ); // header, text, body, charformat, paraFormat // Complete processing the message PostprocessEntryL( *msvEntry, entry ); CleanupStack::PopAndDestroy(); //store msvEntry->Session().CleanupEntryPop(); //entry CleanupStack::PopAndDestroy(2); //details, msvEntry }
// ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // void CIpsSosAOImapPopLogic::HandleMsvSessionEventL( MMsvSessionObserver::TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/ ) { FUNC_LOG; switch( aEvent ) { case MMsvSessionObserver::EMsvEntriesCreated: handleEntriesCreatedL(aArg1); break; case MMsvSessionObserver::EMsvEntriesChanged: { TMsvId parent = (*(TMsvId*) (aArg2)); //we check that parent is the root. if not, it cannot be an //event from service, thus can't be from connection change.. if ( parent == KMsvRootIndexEntryId ) { const CMsvEntrySelection* selection = static_cast<CMsvEntrySelection*>( aArg1 ); TMsvEntry tEntry; TMsvId service; if ( selection->Count() ) { iSession.GetEntry( selection->At(0), service, tEntry ); } if ( !tEntry.Connected() ) { SendCommandToSpecificMailboxL( tEntry.Id(), CIpsSosAOMBoxLogic::ECommandClearDoNotDisconnect ); } } } break; case MMsvSessionObserver::EMsvEntriesDeleted: { TMsvId parent = (*(TMsvId*) (aArg2)); //we check that parent is the root. if not, it cannot be an //event indicating deleted mailbox entry if ( parent == KMsvRootIndexEntryId ) { RemoveOrphanLogicsL(); } } break; case MMsvSessionObserver::EMsvEntriesMoved: default: break; }; }
// ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- TBool CIpsSosAOImapAgent::IsConnected() const { FUNC_LOG; TBool ret = EFalse; TMsvEntry tentry; TMsvId service; TInt err = iSession.GetEntry( iServiceId, service, tentry ); if ( err == KErrNone ) { ret = tentry.Connected(); } return ret; }
void CTestSearchSortDeltaCache::AddEntry() { _LIT(KFunction, "AddEntry"); INFO_PRINTF1(KFunction); TSecureId aOwnerId = 0x999; sampleTMsvEntry.iDate.UniversalTime(); sampleTMsvEntry.SetParent(4096); sampleTMsvEntry.iType = KUidMsvMessageEntry; sampleTMsvEntry.SetId(10); iIndexAdapter->AddEntry(sampleTMsvEntry, aOwnerId, ETrue); ASSERT_TRUE(iSearchSortDeltaCache->iNewEntry.Count() == 1 ); }
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 }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CSMSSender::DeleteEntryL(TMsvEntry& aMsvEntry) { // Take a handle to the parent entry CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession, aMsvEntry.Parent(), TMsvSelectionOrdering()); CleanupStack::PushL(parentEntry); // here parentEntry is the Sent folder (must be so that we can call DeleteL) iOperation = parentEntry->DeleteL(aMsvEntry.Id(), iStatus); CleanupStack::PopAndDestroy(parentEntry); SetActive(); }
// ----------------------------------------------------------------------------- // 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" ) ); }
EXPORT_C TInt CMsvServerEntry::DeleteEntry(TMsvId aId) // // Deletes the child of the current context recursively. // /** Deletes a child entry of the context. The delete works recursively through all the descendants. If a child or any descendant is locked by another client, then no entries are deleted. @param aId The ID of the entry to delete @return KErrNone if successful, KErrAccessDenied if the entry or a descendant was locked by another client, KErrInUse if the store or a file associated with the entry is open, or KErrNotFound if the entry is not a child of the context. */ { __ASSERT_DEBUG(iEntry.Id()!=KMsvNullIndexEntryId, PanicServer(EMsvEntryWithNoContext4)); __ASSERT_DEBUG(aId!=iEntry.Id(), PanicServer(EMsvDeletingCurrentContext)); // only delete children if (!IsAChild(aId)) return KErrNotFound; // get the total selection of entries to be deleted CMsvEntrySelection* movedEntries=NULL; CMsvEntrySelection* deletedEntries=NULL; TRAPD(error, DoDeleteEntryL(aId, deletedEntries, movedEntries)); // notify server of the deletions & moves if (deletedEntries && movedEntries && (deletedEntries->Count() || movedEntries->Count())) { if (deletedEntries->Count()) iServer.NotifyChanged(EMsvEntriesDeleted, *deletedEntries, iEntry.Id()); if (movedEntries->Count()) iServer.NotifyChanged(EMsvEntriesMoved, *movedEntries, KMsvDeletedEntryFolderEntryId, iEntry.Id()); // need to remove owner flag if has no children TMsvEntry* pEntry; TInt err = KErrNone; err = iServer.IndexAdapter().GetEntry(iEntry.Id(), pEntry); if (err ==KErrNone) iEntry.SetOwner(pEntry->Owner()); } delete movedEntries; delete deletedEntries; return error; }
/** ConstructL() Used to ensure that MMsvAttachmentManager is not destroyed until we want it to be. To do this we need to preserve certain objects of CImEmailMessage, which if disappeared would invalidate MMsvAttachmentManager. But this should be deleted in a controlled manner. @param aSession An object of type CMsvSession object. @param aEntry An object of type TMsvEntry used to get the entry ID. */ void CAttachmentItem::ConstructL(CMsvSession& aSession, TMsvEntry aEntry) { iMsvEntry = aSession.GetEntryL(aEntry.Id()); iMsvEntry->SetEntryL(aEntry.Id()); iEmailMsg = CImEmailMessage::NewL(*iMsvEntry); CMsvOperationActiveSchedulerWait* waiter = CMsvOperationActiveSchedulerWait::NewLC(); iEmailMsg->GetAttachmentsListL(waiter->iStatus, aEntry.Id(), CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly); waiter->Start(); CleanupStack::PopAndDestroy(1, waiter); //waiter }