serviceproviders/sapi_messaging/tsrc/dev/tmessagingtest/tmsg_getheaderlistiter1/src/tgetheaderlistsms1.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 24 Nov 2009 08:56:33 +0200
changeset 33 50974a8b132e
parent 19 989d2f495d90
permissions -rw-r--r--
Revision: 200945 Kit: 200948

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  
*
*/

 

#include <e32base.h>
////#include <senduiconsts.h>
#include "messagingservice.h"
#include <badesca.h>
#include "getheader.h"
#include <f32file.h>
#include "messageheader.h"
#ifdef MAIN
#define getheader_test1 main
#endif

int getheader_test1(int, char**)
	{
     __UHEAP_MARK;
    CMessagingService* test = (CMessagingService* ) CMessagingService::NewL() ; 
	CleanupStack::PushL(test);	
	
    CFilterParamInfo* filterParams = CFilterParamInfo::NewL();
    CleanupStack::PushL(filterParams);

	_LIT(Kaddr1, "9008032761");
    filterParams->AddFromL(Kaddr1);
    
    
    filterParams->SetSortType(EMsvSortByNone);
 
    filterParams->AddMtmL(_L("SMS"));
   CMsvEntrySelection* entryselection = NULL ;
   TRAPD(errcode, test->GetIdListL(filterParams,0,NULL,entryselection));

   if(errcode != KErrNone)
      return errcode;
   
   if(entryselection)
		CleanupStack::PushL(entryselection);
   
	
	TInt index = 0;
	TInt val = 0;
	TInt iter=0;
	for(;;)
	{
		CMessageHeader* header = NULL;
		test->GetNextHeaderL(filterParams, entryselection, index, NULL, header);
		if(header)
			{
		     iter++;
		     if((header->Mtm().FindF(_L("SMS")) != KErrNotFound) && (header->From().FindF(_L("9008032761")) != KErrNotFound))
		        val++;
		      
			delete header;
			}
		else
		    break;	
		
	}
	
	

    if(entryselection)
    	CleanupStack::PopAndDestroy(entryselection);
    	     
	CleanupStack::PopAndDestroy(filterParams);
    CleanupStack::PopAndDestroy(test);
     __UHEAP_MARKEND;  
	
	if(iter == val)
		return KErrNone;
	else
		return KErrGeneral;
	}