serviceproviders/sapi_messaging/tsrc/dev/tmessagingtest/tmsg_getheaderlistiter1/src/tgetheaderlistsms3.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     1
/*
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     8
*
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    11
*
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    12
* Contributors:
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    13
*
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    14
* Description:  
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    15
*
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    16
*/
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    17
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    18
 
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    19
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    20
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    21
#include <e32base.h>
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    22
////#include <senduiconsts.h>
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    23
#include "messagingservice.h"
33
50974a8b132e Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 19
diff changeset
    24
#include <badesca.h>
19
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    25
#include "getheader.h"
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    26
#include <f32file.h>
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    27
#include "messageheader.h"
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    28
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    29
#ifdef MAIN
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    30
#define getheader_test3 main
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    31
#endif
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    32
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    33
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    34
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    35
int getheader_test3(int, char**)
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    36
	{
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    37
     __UHEAP_MARK;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    38
    CMessagingService* test = (CMessagingService* ) CMessagingService::NewL() ; 
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    39
	CleanupStack::PushL(test);	
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    40
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    41
    CFilterParamInfo* filterParams = CFilterParamInfo::NewL();
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    42
    CleanupStack::PushL(filterParams);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    43
	_LIT(Kaddr1, "9008032761");
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    44
    
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    45
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    46
  	filterParams->AddFromL(Kaddr1);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    47
  	
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    48
   
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    49
    
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    50
    filterParams->SetSortType( EMsvSortByDate );
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    51
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    52
	filterParams->AddMtmL(_L("SMS"));
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    53
    
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    54
    
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    55
    TDateTime start(2007,EMarch,22,0,0,0,0);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    56
    TInt startyear = start.Year();
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    57
    TInt startmonth = start.Month();
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    58
    TInt startday = start.Day();
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    59
    
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    60
    TTime startdate(start);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    61
    
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    62
    filterParams->SetStartDateFilter(startdate);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    63
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    64
    TDateTime end(2007,EJune,23,0,0,0,0);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    65
    TInt endyear = end.Year();
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    66
    TInt endmonth = end.Month();
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    67
    TInt endday = end.Day();
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    68
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    69
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    70
    TTime enddate(end) ;       
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    71
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    72
	filterParams->SetEndDate(enddate);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    73
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    74
   
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    75
    
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    76
   CMsvEntrySelection* entryselection = NULL ;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    77
    
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    78
   TRAPD(errcode, test->GetIdListL(filterParams,0,NULL,entryselection));
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    79
   if(entryselection)
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    80
		CleanupStack::PushL(entryselection);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    81
	if(errcode != KErrNone)
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    82
		return errcode;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    83
	
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    84
	TInt index = 0;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    85
	TInt val = 0;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    86
	TInt iter=0;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    87
	for(;;)
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    88
	{
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    89
		CMessageHeader* header = NULL;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    90
		test->GetNextHeaderL(filterParams, entryselection, index, NULL, header);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    91
		if(header)
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    92
			{
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    93
		     iter++;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    94
		     
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    95
		     TTime temp = header->Time();
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    96
		     
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    97
		    if((header->Mtm().FindF(_L("SMS")) != KErrNotFound) && (header->From().FindF(_L("9008032761")) != KErrNotFound)
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    98
		    && (startdate <= temp && temp <= enddate ) )
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
    99
		        		        val++;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   100
		      
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   101
			delete header;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   102
			}
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   103
		else
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   104
		    break;	
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   105
		
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   106
	}
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   107
	
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   108
	
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   109
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   110
    if(entryselection)
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   111
    	CleanupStack::PopAndDestroy(entryselection);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   112
    	     
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   113
	CleanupStack::PopAndDestroy(filterParams);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   114
    CleanupStack::PopAndDestroy(test);
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   115
     __UHEAP_MARKEND;  
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   116
	
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   117
	if(iter == val)
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   118
		return KErrNone;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   119
	else
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   120
		return KErrGeneral;
989d2f495d90 Revision: 200923
Pat Downey <patrick.downey@nokia.com>
parents:
diff changeset
   121
	}