examples/Messaging/SearchSortExample/searchsortexample.cpp

00001 /*
00002 Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008 � list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010 � this list of conditions and the following disclaimer in the documentation
00011 � and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013 � may be used to endorse or promote products derived from this software
00014 � without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description:� 
00028 */
00029 
00030 
00031 #include "searchsortexample.h"
00032 #include "mAsyncWaiter.h"
00033 #include <msvsearchsortoperation.h>
00034 
00035 void CSearchsortExample::HandleSessionEventL(TMsvSessionEvent aEvent, TAny*, TAny*, TAny*)
00036         {
00037 
00038         switch (aEvent)
00039                 {
00040                 case MMsvSessionObserver::EMsvServerReady:
00041                         break;
00042                 case MMsvSessionObserver::EMsvEntriesCreated:
00043                         break;
00044                 default:
00045                         break;
00046                 }
00047         }
00048 
00053  CSearchsortExample* CSearchsortExample::NewL()
00054         {
00055         CSearchsortExample* self=new(ELeave)CSearchsortExample;
00056         CleanupStack::PushL(self);
00057         self->ConstructL();
00058         CleanupStack::Pop();
00059         return self;
00060         }
00064 CSearchsortExample::CSearchsortExample()
00065         {
00066         }
00067 
00068 void CSearchsortExample::ConstructL()
00069         {
00070         }
00071 
00075  CSearchsortExample::~ CSearchsortExample()
00076         {
00077         if(iMtm)
00078                 {
00079                 delete iMtm;
00080                 iMtm = NULL;
00081                 }
00082         if(iClientRegistry)
00083                 {
00084                 delete iClientRegistry;
00085                 iClientRegistry  = NULL;
00086                 }
00087         if(iSearch)
00088                 {
00089                 delete iSearch;
00090                 iSearch = NULL;
00091                 }
00092         if(iSession)
00093                 {
00094                 delete iSession;
00095                 iSession = NULL;
00096                 }
00097 
00098         iQueryIdTable.Close();
00099         iTResultSummary.Close();
00100 
00101         }
00102 
00103 
00109 void  CSearchsortExample::CreateClientRegistryL()
00110         {
00111         //Creates a session with message server.
00112         iSession = CMsvSession::OpenAsyncL(*this);
00113         CleanupStack::PushL(iSession);
00114 
00115         iSearch = CMsvSearchSortOperation::NewL(*iSession);
00116         CleanupStack::PushL(iSearch);
00117 
00118         // Create a client-side MTM registry.
00119         iClientRegistry = CClientMtmRegistry::NewL(*iSession,KMsvDefaultTimeoutMicroSeconds32);
00120         if (iClientRegistry != NULL && iClientRegistry->IsPresent(KUidMsgTypePOP3))
00121                 {
00122                 CleanupStack::PushL(iClientRegistry);
00123                 }
00124         // Create a Client-side MTM object for the specified MTM UID.
00125         iMtm = (CPop3ClientMtm*)iClientRegistry->NewMtmL(KUidMsgTypePOP3);
00126 
00127         CleanupStack::Pop(3,iSession); //iClientRegistry,iSession,iSearch.
00128     }
00129 
00136 void  CSearchsortExample::CreatePopAndSmtpAccountL()
00137         {
00138         CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
00139         CImPop3Settings* settings = new(ELeave) CImPop3Settings();
00140         CleanupStack::PushL(settings);
00141 
00142         CImIAPPreferences* popIAP = CImIAPPreferences::NewLC();
00143 
00144         // Set the server address to system address.
00145         settings->SetServerAddressL(KPopServer);
00146         settings->SetLoginNameL(KPopLoginName);
00147         settings->SetPasswordL(KPopPassword);
00148         settings->SetPort(KPortValue);
00149 
00150         // Create a Pop account.
00151         iPopAccount = emailAccounts->CreatePopAccountL(KTxtAccountName, *settings,*popIAP,EFalse);
00152 
00153         CImSmtpSettings *smtpSettings = new (ELeave) CImSmtpSettings();
00154         CleanupStack::PushL(smtpSettings);
00155 
00156         emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings, *popIAP);
00157 
00158         // Create an Smtp acoount.
00159         iSmtpAccount = emailAccounts->CreateSmtpAccountL(iPopAccount, *smtpSettings, *popIAP, EFalse);
00160 
00161         emailAccounts->SetDefaultSmtpAccountL(iSmtpAccount);
00162 
00163         smtpSettings->SetServerAddressL(KSmtpServerAddress);
00164         smtpSettings->SetEmailAliasL(KEmailAlias);
00165         smtpSettings->SetEmailAddressL(KSmtpEmailAddress);
00166         smtpSettings->SetReplyToAddressL(KSmtpEmailAddress);
00167         smtpSettings->SetReceiptAddressL(KSmtpEmailAddress);
00168         smtpSettings->SetPort(KSmtpPortValue);
00169 
00170         // Add IAP to the IAP preferences.
00171         CImIAPPreferences* prefs = CImIAPPreferences::NewLC();
00172         TImIAPChoice iap;
00173         TInt iapID = 0;
00174         CMDBSession* dbSession = CMDBSession::NewL(KCDVersion1_1);
00175         CleanupStack::PushL(dbSession);
00176         CCDConnectionPrefsRecord *connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord));
00177         CleanupStack::PushL(connPrefRecord);
00178 
00179         // Set the direction of connection.
00180         connPrefRecord->iDirection = ECommDbConnectionDirectionOutgoing;
00181         connPrefRecord->iRanking = 1;
00182         if(!connPrefRecord->FindL(*dbSession))
00183                 {
00184                 User::Leave(KErrNotFound);
00185                 }
00186         iapID = connPrefRecord->iDefaultIAP;
00187         iap.iIAP = iapID;
00188         iap.iDialogPref = ECommDbDialogPrefDoNotPrompt;
00189         prefs->AddIAPL(iap);
00190 
00191         emailAccounts->GetSmtpAccountL(iSmtpAccount.iSmtpService, iSmtpAccount);
00192         emailAccounts->SaveSmtpSettingsL(iSmtpAccount,*smtpSettings);
00193         emailAccounts->SaveSmtpIapSettingsL(iSmtpAccount, *prefs);
00194 
00195         //Deleting the message entries if they exist for resetting.
00196         DeleteSmtpMessageL();
00197         //connPrefRecord, dbSession, prefs, smtpSettings, popIAP, settings, emailAccounts.
00198         CleanupStack::PopAndDestroy(7,emailAccounts);
00199         }
00200 
00205 void  CSearchsortExample::CreateSmtpMessageL(TInt aindex,TDes& aFrominfo,TDes& aToinfo,TDes& aSubjectinfo)
00206         {
00207 
00208         TMsvId inboxId = KMsvGlobalInBoxIndexEntryId;
00209 
00210         // Set the context to the folder in which message has to be created.
00211         CMsvEntry*      entry = CMsvEntry::NewL(*iSession,inboxId,TMsvSelectionOrdering());
00212         CleanupStack::PushL(entry);
00213         entry->SetEntryL(inboxId);
00214 
00215         CMessAsyncWaiter* waiter = CMessAsyncWaiter::NewL();
00216         CleanupStack::PushL(waiter);
00217 
00218         TMsvEmailTypeList msvEmailTypeList = 0;
00219         TMsvPartList partList = (KMsvMessagePartBody | KMsvMessagePartAttachments|KMsvMessagePartTo|KMsvMessagePartFrom|KMsvMessagePartSubject);
00220 
00221         CImEmailOperation* emailOperation = CImEmailOperation::CreateNewL(waiter->iStatus, *iSession,KMsvGlobalInBoxIndexEntryId, partList, msvEmailTypeList, KUidMsgTypeSMTP);
00222         CleanupStack::PushL(emailOperation);
00223         waiter->StartAndWait();
00224 
00225         TMsvId temp;
00226         TPckgC<TMsvId> paramPack(temp);
00227         const TDesC8& progBuf = emailOperation->ProgressL();
00228 
00229         paramPack.Set(progBuf);
00230         TMsvId newMessageId;
00231         newMessageId = paramPack();
00232 
00233 
00234         entry->SetEntryL(newMessageId);
00235 
00236         CMsvStore* store = entry->EditStoreL();
00237         CleanupStack::PushL(store);
00238 
00239         //Setting the Header for message entry.
00240         CImHeader* emailEntry = CImHeader::NewLC();
00241         emailEntry->RestoreL(*store);
00242 
00243         //Setting the Header according to the message entry count.
00244         switch(aindex)
00245                 {
00246                 case 0:
00247                         {
00248                         emailEntry->SetFromL((TDesC8&)KFrom1);
00249                         emailEntry->SetSubjectL((TDesC&)KSubject1);
00250                         emailEntry->ToRecipients().AppendL((TDesC&)KTo1);
00251                         aToinfo.Copy(KTo1);
00252                         }
00253                         break;
00254                 case 1:
00255                         {
00256                         emailEntry->SetFromL((TDesC8&)KFrom2);
00257                         emailEntry->SetSubjectL((TDesC&)KSubject2);
00258                         emailEntry->ToRecipients().AppendL((TDesC&)KTo2);
00259                         aToinfo.Copy(KTo2);
00260                         }
00261                         break;
00262                 case 2:
00263                         {
00264                         emailEntry->SetFromL((TDesC8&)KFrom3);
00265                         emailEntry->SetSubjectL((TDesC&)KSubject3);
00266                         emailEntry->ToRecipients().AppendL((TDesC&)KTo3);
00267                         aToinfo.Copy(KTo3);
00268                         }
00269                         break;
00270                 case 3:
00271                         {
00272                         emailEntry->SetFromL((TDesC8&)KFrom4);
00273                         emailEntry->SetSubjectL((TDesC&)KSubject4);
00274                         emailEntry->ToRecipients().AppendL((TDesC&)KTo4);
00275                         aToinfo.Copy(KTo4);
00276                         }
00277                         break;
00278                 case 4:
00279                         {
00280                         emailEntry->SetFromL((TDesC8&)KFrom5);
00281                         emailEntry->SetSubjectL((TDesC&)KSubject5);
00282                         emailEntry->ToRecipients().AppendL((TDesC&)KTo5);
00283                         aToinfo.Copy(KTo5);
00284                         }
00285                         break;
00286                 default:
00287                         break;
00288                 }
00289 
00290         aFrominfo.Copy(emailEntry->From());
00291         aSubjectinfo.Copy(emailEntry->Subject());
00292 
00293         // Paragraph format layer for the rich text object.
00294         CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
00295         CleanupStack::PushL(paraFormatLayer);
00296         // Character format layer for the rich text object.
00297         CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
00298         CleanupStack::PushL(charFormatLayer);
00299 
00300         CRichText* bodyText = CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256);
00301         CleanupStack::PushL(bodyText);
00302 
00303         // Inserts the contents of a buffer into the document at specified position.
00304         bodyText->InsertL(0, KBodyContents);
00305         store->StoreBodyTextL(*bodyText);
00306         emailEntry->StoreL(*store);
00307         // Store the changes permanently.
00308         store->CommitL();
00309 
00310         // bodyText, charFormatLayer, paraFormatLayer, emailEntry, store, emailOperation, waiter, entry.
00311         CleanupStack::PopAndDestroy(8,entry);
00312         }
00313 
00314 
00318 void CSearchsortExample::SearchSortRequestWithoutIteratorL(TDes& aSearchtext,TBool aCaseSensitivity,TBool aWholeWordSearch,TBool aCombinedSearch,TInt& aResultCount)
00319         {
00320 
00321         //CMessAsyncWaiter for async request.
00322         CMessAsyncWaiter* waiter = CMessAsyncWaiter::NewL();
00323         CleanupStack::PushL(waiter);
00324 
00325         //Create instance of CMsvSearchSortQuery to create a search-sort query.
00326         CMsvSearchSortQuery* searchQuery = CMsvSearchSortQuery::NewL();
00327         CleanupStack::PushL(searchQuery);
00328 
00329         //Search-sort operation is performed on a specified folder. (e.g, on INBOX, SENT ITEMS,
00330         //DRAFT, OUTBOX or any user created folder). Needs to sets the value of the folder entry.
00331         searchQuery->SetParentId(KMsvGlobalInBoxIndexEntryIdValue);
00332         //Sets the type of result expected out of the search-sort operation.
00333         searchQuery->SetResultType(EMsvResultAsTMsvEntry);
00334         searchQuery->SetWholeWord(aWholeWordSearch);
00335         searchQuery->SetCaseSensitiveOption(aCaseSensitivity);
00336         searchQuery->SetWildCardSearch(EFalse);
00337 
00338         //Adding search option.
00339         searchQuery->AddSearchOptionL(EMsvTo,aSearchtext, EMsvEqual);
00340 
00341         //Combined search-sort we can add some more AddSearchOptionL function.
00342         if(aCombinedSearch)
00343                 {
00344                 TInt size = KSize;
00345                 //Adding search option.
00346                 searchQuery->AddSearchOptionL(EMsvSize, size, EMsvLessThanOrEqual);
00347                 searchQuery->AddSearchOptionL(EMsvSubject, KSubjectSearch, EMsvEqual);
00348 
00349                 }
00350 
00351         //Adding sort option.
00352         searchQuery->AddSortOptionL(EMsvDate, EMsvSortAscending);
00353 
00354         //Poping the searchQuery object from cleanupstack as here after.
00355         //the control transfers to CMsvSearchSortOperation by making a call to RequestL.
00356         CleanupStack::Pop(searchQuery);
00357 
00358         //Search-sort Request.
00359         iSearch->RequestL(searchQuery, ETrue, waiter->iStatus);
00360         waiter->StartAndWait();
00361 
00362         //To hold Search-sort results.
00363         RArray<TMsvEntry> resultArray;
00364 
00365         //After the completion RequestL(), GetResultsL function provides a list of
00366         //index entry Id objects (TMsvEntry).
00367         TRAPD(ret, iSearch->GetResultsL(resultArray));
00368 
00369         iTResultSummary.Reset();
00370 
00371         TMsvId inboxId=KMsvGlobalInBoxIndexEntryId;
00372         CMsvEntry*      entry = CMsvEntry::NewL(*iSession,inboxId,TMsvSelectionOrdering());
00373         CleanupStack::PushL(entry);
00374 
00375         if(ret == KErrNone)
00376                 {
00377                 //for getting and the entry details.
00378                 for(TInt index=0;index<resultArray.Count();index++)
00379                         {
00380                         TResultSummary tempdata;
00381                         TMsvEntry tempentry;
00382                         TTime date;
00383 
00384                         tempentry=resultArray[index];
00385                         entry->SetEntryL(tempentry.Id());
00386 
00387                         //For obtaining header info.
00388                         CMsvStore* store = entry->ReadStoreL();
00389                         CleanupStack::PushL(store);
00390                         CImHeader* emailEntry = CImHeader::NewLC();
00391                         emailEntry->RestoreL(*store);
00392 
00393                         tempdata.iSubjectText.Copy(emailEntry->Subject());
00394                         tempdata.iToText.Copy((emailEntry->ToRecipients())[0]);
00395                         tempdata.iSize=tempentry.iSize;
00396                         date=tempentry.iDate;
00397                         date.FormatL(tempdata.iDatestring,KFormat1);
00398                         date.FormatL(tempdata.iTimestring,KFormat2);
00399                         iTResultSummary.Append(tempdata);
00400 
00401                         CleanupStack::PopAndDestroy(2,store); //emailEntry, store.
00402                         }
00403                 aResultCount=iSearch->GetResultCountL();
00404                 }
00405         //After the completion of RequestL(), GetQueryIdL function provides the query Id.
00406         //corresponding to a search-sort query.
00407         iQueryId = iSearch->GetQueryIdL();
00408 
00409         iExampleTQueryTable.iQueryId=iQueryId;
00410         iExampleTQueryTable.iResultType=EMsvResultAsTMsvEntry;
00411         iQueryIdTable.Append(iExampleTQueryTable);
00412 
00413         resultArray.Close();
00414         CleanupStack::PopAndDestroy(2,waiter); //entry, waiter.
00415         }
00416 
00420 void CSearchsortExample::SearchSortRequestWithIteratorL(TInt& aResultCount)
00421         {
00422 
00423         //CMessAsyncWaiter for async request.
00424         CMessAsyncWaiter* waiter = CMessAsyncWaiter::NewL();
00425         CleanupStack::PushL(waiter);
00426 
00427         //Create instance of CMsvSearchSortQuery to create a search-sort query.
00428         CMsvSearchSortQuery* searchQuery = CMsvSearchSortQuery::NewL();
00429         CleanupStack::PushL(searchQuery);
00430 
00431         //Search-sort operation is performed on a specified folder. (e.g, on INBOX, SENT ITEMS,
00432         //DRAFT, OUTBOX or any user created folder). Needs to sets the value of the folder entry.
00433         searchQuery->SetParentId(KMsvGlobalInBoxIndexEntryIdValue);
00434         //Sets the type of result expected out of the search-sort operation.
00435         searchQuery->SetResultType(EMsvResultAsTMsvId);
00436         searchQuery->SetWholeWord(ETrue);
00437         searchQuery->SetCaseSensitiveOption(EFalse);
00438         searchQuery->SetWildCardSearch(EFalse);
00439 
00440 
00441         TInt size = KSize;
00442         //Add search option.
00443         searchQuery->AddSearchOptionL(EMsvSize, size, EMsvLessThanOrEqual);
00444 
00445         //Add sort option.
00446         searchQuery->AddSortOptionL(EMsvDate, EMsvSortAscending);
00447 
00448         //to enable Iterator.
00449         TInt iterator = 1;
00450 
00451         //Poping the searchQuery object from cleanupstack as here after.
00452         //the control transfers to CMsvSearchSortOperation by making a call to RequestL.
00453         CleanupStack::Pop(searchQuery);
00454         //Search-sort Request.
00455         iSearch->RequestL(searchQuery, ETrue, waiter->iStatus,iterator);
00456         waiter->StartAndWait();
00457 
00458         //Array to copy Search-sort results.
00459         RArray<TMsvId> resultArray;
00460         TMsvId resultAsTMsvId;
00461 
00462 
00463         //Gets the TMsvId of a single index entry object at a time.
00464         //GetNextResultL function is used when getting the results using iterative mechanism
00465         //and it returns remaining search-sort results Count.
00466         while(iSearch->GetNextResultL(resultAsTMsvId))
00467                 {
00468                 resultArray.AppendL(resultAsTMsvId);
00469                 }
00470 
00471         aResultCount=iSearch->GetResultCountL();
00472 
00473         resultArray.Close();
00474         CleanupStack::PopAndDestroy(waiter); //waiter.
00475         }
00476 
00480 void CSearchsortExample::SearchSortRequestByQueryIdL(TInt& aResultCount)
00481         {
00482 
00483 
00484         //CMessAsyncWaiter for async request.
00485         CMessAsyncWaiter* waiter = CMessAsyncWaiter::NewL();
00486         CleanupStack::PushL(waiter);
00487 
00488         //Search-sort Request by QueryId.
00489         iSearch->RequestL(iQueryId, waiter->iStatus);
00490         waiter->StartAndWait();
00491 
00492 
00493         //To hold Search-sort results.
00494         TInt count=iQueryIdTable.Count();
00495         TQueryTable tempdata;
00496 
00497         TMsvId inboxId=KMsvGlobalInBoxIndexEntryId;
00498         CMsvEntry*      entry = CMsvEntry::NewL(*iSession,inboxId,TMsvSelectionOrdering());
00499         CleanupStack::PushL(entry);
00500 
00501         iTResultSummary.Reset();
00502         for(TInt index=0;index<count;index++)
00503                 {
00504                 tempdata=iQueryIdTable[index];
00505                 if(tempdata.iQueryId==iQueryId)
00506                         {
00507                         if(tempdata.iResultType==EMsvResultAsTMsvId)
00508                                 {
00509                                 RArray<TMsvId> resultArray;
00510                                 TRAPD(ret, iSearch->GetResultsL(resultArray));
00511                                 if(ret == KErrNone)
00512                                         {
00513                                         TInt count = resultArray.Count();
00514                                         aResultCount=count;
00515                                         }
00516                                 resultArray.Close();
00517                                 }
00518                         else if(tempdata.iResultType==EMsvResultAsTMsvEntry)
00519                                 {
00520                                 RArray<TMsvEntry> resultArray;
00521                                 TRAPD(ret, iSearch->GetResultsL(resultArray));
00522                                 if(ret == KErrNone)
00523                                         {
00524                                         TInt count = resultArray.Count();
00525                                         aResultCount=count;
00526 
00527                                         //for getting the entry details.
00528                                         for(TInt index=0;index<count;index++)
00529                                                 {
00530                                                 TResultSummary tempdata;
00531                                                 TMsvEntry tempentry;
00532                                                 TTime date;
00533 
00534 
00535                                                 tempentry=resultArray[index];
00536                                                 entry->SetEntryL(tempentry.Id());
00537 
00538                                                 //for getting header info.
00539                                                 CMsvStore* store = entry->ReadStoreL();
00540                                                 CleanupStack::PushL(store);
00541                                                 CImHeader* emailEntry = CImHeader::NewLC();
00542                                                 emailEntry->RestoreL(*store);
00543 
00544 
00545                                                 tempdata.iSubjectText.Copy(emailEntry->Subject());
00546                                                 tempdata.iToText.Copy((emailEntry->ToRecipients())[0]);
00547                                                 tempdata.iSize=tempentry.iSize;
00548                                                 date=tempentry.iDate;
00549                                                 date.FormatL(tempdata.iDatestring,KFormat1);
00550                                                 date.FormatL(tempdata.iTimestring,KFormat2);
00551                                                 iTResultSummary.Append(tempdata);
00552 
00553                                                 CleanupStack::PopAndDestroy(2,store);
00554                                                 }
00555                                         }
00556                                         resultArray.Close();
00557                                 }
00558                         }
00559                 }
00560         CleanupStack::PopAndDestroy(2,waiter); // entry, waiter.
00561         }
00562 
00566 void  CSearchsortExample::DeleteSmtpMessageL()
00567         {
00568         //CMessAsyncWaiter for async request.
00569 
00570         CMessAsyncWaiter* waiter = CMessAsyncWaiter::NewL();
00571         CleanupStack::PushL(waiter);
00572 
00573         TInt mycount;
00574         TMsvId inboxId = KMsvGlobalInBoxIndexEntryId;
00575         CMsvEntry*      messagingEntry = CMsvEntry::NewL(*iSession,inboxId,TMsvSelectionOrdering());
00576         CleanupStack::PushL(messagingEntry);
00577         messagingEntry->SetEntryL(inboxId);
00578 
00579         CMsvEntrySelection* filteredMessageIds =messagingEntry->ChildrenL();
00580         CleanupStack::PushL( filteredMessageIds);
00581          mycount=filteredMessageIds->Count();
00582         if(mycount)
00583                 {
00584                 CMsvOperation* operation = messagingEntry->DeleteL(*filteredMessageIds,waiter->iStatus);
00585                 CleanupStack::PushL(operation);
00586                 waiter->StartAndWait();
00587                 CleanupStack::PopAndDestroy();
00588                 }
00589         CleanupStack::PopAndDestroy(3,waiter); //filteredMessageIds, messagingEntry, waiter.
00590         }
00591 
00592 void CSearchsortExample::DeleteAccountsL()
00593         {
00594 
00595         CEmailAccounts* accounts = CEmailAccounts::NewLC();
00596 
00597         RArray<TPopAccount>     pop3Accounts;
00598         CleanupClosePushL(pop3Accounts);
00599         accounts->GetPopAccountsL(pop3Accounts);
00600         TInt    count = pop3Accounts.Count();
00601         TInt    index=0;
00602         for( index = 0; index < count; index++ )
00603                 {
00604                 TPopAccount     id = pop3Accounts[index];
00605 
00606                 TRAPD(err,accounts->DeletePopAccountL( id ));
00607                 if(err!=KErrNone)
00608                         {
00609                         User::Panic(KUserPanic, err);
00610                         }
00611                 }
00612 
00613         RArray<TImapAccount>    imap4Accounts;
00614         CleanupClosePushL(imap4Accounts);
00615         accounts->GetImapAccountsL(imap4Accounts);
00616         count = imap4Accounts.Count();
00617         for( TInt index = 0; index < count; index++ )
00618                 {
00619                 TImapAccount    id = imap4Accounts[index];
00620                 TRAPD(err,accounts->DeleteImapAccountL( id ));
00621                 if(err!=KErrNone)
00622                         {
00623                         User::Panic(KUserPanic, err);
00624                         }
00625                 }
00626 
00627         RArray<TSmtpAccount>    smtpAccounts;
00628         CleanupClosePushL(smtpAccounts);
00629         accounts->GetSmtpAccountsL(smtpAccounts);
00630 
00631     count = smtpAccounts.Count();
00632     for( TInt index = 0; index < count; index++ )
00633                 {
00634                 TSmtpAccount    id = smtpAccounts[index];
00635 
00636                 TRAPD(err,accounts->DeleteSmtpAccountL( id ));
00637                 if(err!=KErrNone)
00638                         {
00639                         User::Panic(KUserPanic, err);
00640                         }
00641                 }
00642         CleanupStack::PopAndDestroy(4, accounts);
00643         }
00644 

Generated by  doxygen 1.6.2