//--------------------------------------------------------------- // TestUniDataModelPlugin::initTestCase //--------------------------------------------------------------- void TestUniDataModelMMSPlugin::initTestCase() { iObserver = new (ELeave) TestObserverMMS(); // Create a new messaging server session.. TRAPD(err,iMSession = CMsvSession::OpenSyncL(*iObserver)); if(err) { TInt x = err; } // Create the client mtm registry CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL(*iMSession); // Get the MMS clientmtm iMmsClientMtm = static_cast<CMmsClientMtm*> (mtmReg->NewMtmL(KUidMsgTypeMultimedia)); //Connecting to File Server Session User::LeaveIfError( iFs.Connect() ); iFs.SetSessionPath( KRootPath ); //Getting Service ID for MMS CMmsSettings* settings = CMmsSettings::NewL(); settings->LoadSettingsL(); iServiceId = settings->Service(); iMessageId = 0; //Saving the Timestamp before Message is created retTimeStamp = QDateTime::currentDateTime(); // Get the MMS data modelplugin pluginLoader = new UniDataModelLoader; pluginInterface = pluginLoader->getDataModelPlugin(ConvergedMessage::Mms); }
void CTestMessSharedData::CMsgIMAP4ConnectAndSyncComplete::DoProcessL(CClientMtmRegistry& aMtmRegistry) { iBaseMtm=aMtmRegistry.NewMtmL(iMtmId); CActiveScheduler::Add(this); iBaseMtm->SwitchCurrentEntryL(iMsvId); CMsvEntrySelection* selection=new (ELeave) CMsvEntrySelection(); CleanupStack::PushL(selection); selection->Reset(); selection->AppendL(iMsvId); selection->AppendL(iMsvId); // remote inbox TPckg<MMsvImapConnectionObserver*> parameter(this); iOperation=iBaseMtm->InvokeAsyncFunctionL(KIMAP4MTMConnectAndSyncCompleteAfterDisconnect, *selection, parameter, iStatus); CleanupStack::PopAndDestroy(selection); SetActive(); }
void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId ) { CMsvEntry* messageEntry = iMsvSession->GetEntryL(aMessageId); CleanupStack::PushL(messageEntry); TMsvEntry entry = messageEntry->Entry(); if(entry.MtmData1() == KUidMsgTypeBtTInt32) { CMsvStore* store = messageEntry->ReadStoreL(); CleanupStack::PushL(store); TInt attachmentCount = store->AttachmentManagerL().AttachmentCount(); RFile attachmentFile; if(attachmentCount != 0) { //get file handle for the attachment & the complete path of the file attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = messageEntry->Entry(); attachEntry.SetUnread(EFalse); messageEntry->ChangeL(attachEntry); } else { CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL(*iMsvSession); CleanupStack::PushL(mtmReg); //1st Push CBIOClientMtm* bioClientMtm = (CBIOClientMtm*) mtmReg->NewMtmL(KBioUidValueUid); CleanupStack::PushL(bioClientMtm); //2nd Push bioClientMtm->SwitchCurrentEntryL(aMessageId); CMsvEntry* attachmentEntry = CMsvEntry::NewL(bioClientMtm->Session(), aMessageId, TMsvSelectionOrdering()); CleanupStack::PushL(attachmentEntry); //3rd Push bioClientMtm->LoadMessageL(); CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(selection); //4th Push selection->AppendL(aMessageId); TBuf8<1> aParameter; CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC(); //5th Push CMsvOperation* operation = bioClientMtm->InvokeAsyncFunctionL(KBiosMtmParse, *selection, aParameter, wait->iStatus); wait->Start(); CMsvStore* store = attachmentEntry->ReadStoreL(); CleanupStack::PushL(store); //6th Push MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); attachmentFile = attachMan.GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); //7th Push User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = attachmentEntry->Entry(); attachEntry.SetUnread(EFalse); attachmentEntry->ChangeL(attachEntry); delete operation; CleanupStack::PopAndDestroy(6); } CleanupStack::PopAndDestroy(store); } else { CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id()); CleanupStack::PushL(attachmentEntry); //1st push CMsvStore* store = attachmentEntry->ReadStoreL(); CleanupStack::PushL(store); //2nd push TBuf<KMaxPath> attachmentName(store->AttachmentManagerL().GetAttachmentInfoL(0)->AttachmentName()); RFs fs; User::LeaveIfError(fs.Connect()); CleanupClosePushL(fs); TEntry entry; User::LeaveIfError(fs.Entry(attachmentName, entry)); CleanupStack::PopAndDestroy(&fs); //get file handle for the attachment & the complete path of the file RFile attachmentFile; attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0); CleanupClosePushL(attachmentFile); //3rd Push User::LeaveIfError(attachmentFile.FullName(aMsgPath)); CleanupStack::PopAndDestroy(&attachmentFile); StoreMessageMimeTypeL(aMsgPath); //mark attachment as Read TMsvEntry attachEntry = attachmentEntry->Entry(); attachEntry.SetUnread(EFalse); attachmentEntry->ChangeL(attachEntry); CleanupStack::PopAndDestroy(store); CleanupStack::PopAndDestroy(attachmentEntry); } CleanupStack::PopAndDestroy(messageEntry); }
// ----------------------------------------------------------------------------- // CMessageMonitorPlugin::HandleMsgMovedL // ----------------------------------------------------------------------------- // void CMessageMonitorPlugin::HandleMsgMovedL( const TMsvId aFolderId1, const TMsvId aFolderId2, const CMsvEntrySelection& aSelection ) { WRITELOG("ENTER CMessageMonitorPlugin::HandleMsgMovedL"); TInt count( aSelection.Count() ); // cycle through every message in the CMsvEntrySelection for ( TInt i=0; i < count; ++i ) { TMsvId msgId = aSelection[i]; WRITELOG1("msgId: %d", msgId ); TMsvId service = 0; TMsvEntry entry; TInt err = iMsvSession->GetEntry( msgId, service, entry ); // if we have a message and it has been moved from the outbox to the sent // items, and it is a valid message if ( ( !err ) && ( KUidMsvMessageEntry == entry.iType ) && ( KMsvSentEntryId == aFolderId1 ) && ( KMsvGlobalOutBoxIndexEntryId == aFolderId2 ) && ( IsValidMessageTypeL( entry, *iMsvSession ) ) ) { HBufC* uri = CreateUriL( entry.iMtm, msgId ); CleanupStack::PushL( uri ); CHarvesterData* hd = CHarvesterData::NewL( uri ); CleanupStack::Pop( uri ); hd->SetEventType( EHarvesterAdd ); hd->SetTakeSnapshot( EFalse ); hd->SetBinary( EFalse ); iMonitorPluginObserver->MonitorEvent( hd ); } #ifdef __WINSCW__ else if (!err && KMsvDraftEntryId == aFolderId2 && KMsvGlobalOutBoxIndexEntryId == aFolderId1 ) { if( entry.iMtm.iUid != KUidMsgTypeMultimedia.iUid ) { CClientMtmRegistry* clientMtmReg; clientMtmReg = CClientMtmRegistry::NewL(*iMsvSession); CleanupStack::PushL(clientMtmReg); CSmsClientMtm* smsMtm = static_cast<CSmsClientMtm*>(clientMtmReg->NewMtmL(KUidMsgTypeSMS)); CleanupStack::PushL(smsMtm); smsMtm->SwitchCurrentEntryL( msgId ); TMsvSelectionOrdering selection; selection.SetShowInvisibleEntries(ETrue); CMsvEntry* parentEntry = CMsvEntry::NewL( smsMtm->Session(), smsMtm->Entry().Entry().Parent(), selection ); CleanupStack::PushL(parentEntry); // Move the message TRAP_IGNORE( parentEntry->MoveL( msgId, KMsvSentEntryId ) ); CleanupStack::PopAndDestroy(3,clientMtmReg); // parentEntry } } #endif } WRITELOG("END CMessageMonitorPlugin::HandleMsgMovedL"); }
LOCAL_C void TestUiMtmLoadPanicL() { // Make sure the server is closed CMsgsTestUtils::WaitForServerClose(); User::After(500000); TChar driveChar= theUtils->FileSession().GetSystemDriveChar(); TBuf<2> systemDrive; systemDrive.Append(driveChar); systemDrive.Append(KDriveDelimiter); TPath pathName(systemDrive); pathName.Append(KDefaultRegistryFileStoreName); theUtils->FileSession().Delete(pathName); CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray(); CleanupStack::PushL(mtmdllinfoarray); // Create library info with silly imports CMtmDllInfo* mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmServerComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,1,TVersion(2,0,0)); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo); mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmClientComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,1,TVersion(2,0,0)); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo); mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmUiComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,345,TVersion(2,0,0)); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo); mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmUiDataComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,456,TVersion(2,0,0)); mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo); TCapabilitySet capSet; capSet.SetEmpty(); CleanupStack::Pop(mtmdllinfoarray); // next line takes ownership CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(KUidTestMtm, KUidTestMtm, mtmdllinfoarray, capSet); CleanupStack::PushL(mtmgroupdata); CFileStore* filestore = CPermanentFileStore::ReplaceLC(theUtils->FileSession(), KMtmDataFile, EFileShareExclusive|EFileStream|EFileWrite); TUidType uidtype(KPermanentFileStoreLayoutUid,KUidMsvDataComponent, KUidTestMtm); filestore->SetTypeL(uidtype); RStoreWriteStream out; TStreamId streamid=out.CreateLC(*filestore); // Push to stack mtmgroupdata->ExternalizeL(out); out.CommitL(); CleanupStack::PopAndDestroy(); // out filestore->SetRootL(streamid); filestore->CommitL(); CleanupStack::PopAndDestroy(2, mtmgroupdata); // filestore, mtmgroupdata CDummyObserver* ob = new(ELeave)CDummyObserver; CleanupStack::PushL(ob); CMsvSession* session = CMsvSession::OpenSyncL(*ob); CleanupStack::PushL(session); TInt err = session->InstallMtmGroup(KMtmDataFile); test(err == KErrNone || err == KErrAlreadyExists); CClientMtmRegistry* clientReg = CClientMtmRegistry::NewL(*session); CleanupStack::PushL(clientReg); CBaseMtm* client = NULL; client = clientReg->NewMtmL(KUidTestMtm); CleanupStack::PushL(client); CMtmUiRegistry* uiReg = CMtmUiRegistry::NewL(*session); CleanupStack::PushL(uiReg); if (client !=NULL) { TRAPD(error, uiReg->NewMtmUiL(*client)); test(error == KErrBadLibraryEntryPoint); } CleanupStack::PopAndDestroy(5); // uiReg, client, clientReg, session, ob }