smsprotocols/smsstack/test/smspdudb.cpp
author ivan.fildichev@opencode.com
Thu, 18 Nov 2010 15:42:16 +0200
branchopencode
changeset 88 5e27cc612ac7
parent 24 6638e7f4bd8f
permissions -rw-r--r--
Latest bug-fixes with added tests.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     1
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     2
// All rights reserved.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     3
// This component and the accompanying materials are made available
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     5
// which accompanies this distribution, and is available
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     7
//
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     8
// Initial Contributors:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
     9
// Nokia Corporation - initial contribution.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    10
//
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    11
// Contributors:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    12
//
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    13
// Description:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    14
//
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    15
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    16
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    17
#include "smspdudb.h"
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    18
#include <testconfigfileparser.h>
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    19
#include "Gsmumsg.h"
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    20
#include "gsmubuf.h"
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    21
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    22
const TInt KSmsPduDbMaxReadWriteChunk = 0x200;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    23
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    24
EXPORT_C CSmsPduDatabase* CSmsPduDatabase::NewL(RFs& aFs)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    25
/**
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    26
 *  CSmsPduDatabase default factory function
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    27
 *  
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    28
 *  Calls the other overload of NewL with the default section, filename and component.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    29
 */
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    30
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    31
	return NewL(aFs, KSmsPduDbDefaultSection, KSmsPduDbDefaultFilename, KSmsPduDbDefaultComponent);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    32
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    33
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    34
EXPORT_C CSmsPduDatabase* CSmsPduDatabase::NewL(RFs& aFs, const TDesC8& aSection, const TDesC& aFileName, const TDesC& aComponent)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    35
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    36
	CSmsPduDatabase* self = new (ELeave) CSmsPduDatabase(aFs);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    37
	CleanupStack::PushL(self);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    38
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    39
	//Construct iConfigFile and set iSection to aSection
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    40
	CTestConfig*  testConfig = CTestConfig::NewLC(aFs, aComponent, aFileName);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    41
	CleanupStack::Pop(testConfig);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    42
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    43
	self->iConfigFile = testConfig;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    44
	self->SetSectionL(aSection);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    45
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    46
	CleanupStack::Pop(self);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    47
	return self;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    48
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    49
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    50
EXPORT_C CSmsPduDatabase* CSmsPduDatabase::NewL(RFs& aFs, const CTestConfigSection& aSection)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    51
/**
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    52
 *  Constructs a CSmsPduDatabase and sets iSection to aSection.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    53
 *  @note iConfigFile is not constructed and should remain NULL
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    54
 */
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    55
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    56
	CSmsPduDatabase* self = new (ELeave) CSmsPduDatabase(aFs);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    57
	self->SetSection(aSection);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    58
	return self;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    59
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    60
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    61
EXPORT_C CSmsPduDatabase::~CSmsPduDatabase()
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    62
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    63
	delete iConfigFile;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    64
	// @note Don't delete iSection because it is either owned by iConfigFile or by another config file
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    65
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    66
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    67
TPtrC8 CSmsPduDatabase::GetTypeL(CSmsPDU::TSmsPDUType aType) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    68
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    69
	TPtrC8 type;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    70
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    71
	switch (aType)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    72
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    73
		case CSmsPDU::ESmsSubmit:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    74
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    75
			type.Set(KSmsPduDbSubmit);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    76
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    77
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    78
		case CSmsPDU::ESmsDeliver:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    79
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    80
			type.Set(KSmsPduDbDeliver);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    81
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    82
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    83
		case CSmsPDU::ESmsCommand:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    84
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    85
			type.Set(KSmsPduDbCommand);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    86
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    87
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    88
		case CSmsPDU::ESmsStatusReport:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    89
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    90
			type.Set(KSmsPduDbStatusReport);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    91
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    92
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    93
		case CSmsPDU::ESmsSubmitReport:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    94
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    95
			type.Set(KSmsPduDbSubmitReport);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    96
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    97
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    98
		case CSmsPDU::ESmsDeliverReport:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
    99
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   100
			type.Set(KSmsPduDbDeliverReport);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   101
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   102
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   103
		default:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   104
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   105
			User::Leave(KErrNotSupported);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   106
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   107
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   108
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   109
	return type;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   110
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   111
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   112
TPtrC8 CSmsPduDatabase::GetConcatTypeL(CSmsPDU::TSmsPDUType aType) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   113
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   114
	TPtrC8 type;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   115
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   116
	switch (aType)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   117
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   118
		case CSmsPDU::ESmsSubmit:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   119
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   120
			type.Set(KSmsPduDbSubmitConcat);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   121
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   122
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   123
		case CSmsPDU::ESmsDeliver:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   124
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   125
			type.Set(KSmsPduDbDeliverConcat);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   126
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   127
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   128
		default:
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   129
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   130
			User::Leave(KErrNotSupported);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   131
			break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   132
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   133
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   134
	return type;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   135
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   136
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   137
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   138
EXPORT_C CSmsPduDbPdu* CSmsPduDatabase::GetPduLC(CSmsPDU::TSmsPDUType aType, TInt aId) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   139
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   140
	const TPtrC8 type(GetTypeL(aType));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   141
	RSmsPduDbIdArray array(type);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   142
	CleanupClosePushL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   143
	GetIdsL(array, aId);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   144
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   145
	const CTestConfigItem& item = *array[0].iItem;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   146
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   147
	CSmsPduDbPdu* pdu = CSmsPduDbPdu::NewL(iFs, item, aType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   148
	CleanupStack::PopAndDestroy(&array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   149
	CleanupStack::PushL(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   150
	return pdu;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   151
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   152
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   153
EXPORT_C void CSmsPduDatabase::GetPduL(RPointerArray<CSmsPduDbPdu>& aArray, CSmsPDU::TSmsPDUType aType) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   154
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   155
	const TPtrC8 type(GetTypeL(aType));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   156
	RSmsPduDbIdArray array(type);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   157
	CleanupClosePushL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   158
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   159
	GetIdsL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   160
	const TInt count = array.Count();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   161
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   162
	for (TInt i = 0; i < count; i++)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   163
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   164
		CSmsPduDbPdu* pdu = CSmsPduDbPdu::NewL(iFs, *array[i].iItem, aType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   165
		CleanupStack::PushL(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   166
		User::LeaveIfError(aArray.Append(pdu));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   167
		CleanupStack::Pop(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   168
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   169
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   170
	CleanupStack::PopAndDestroy(&array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   171
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   172
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   173
EXPORT_C CSmsPduDbConcatSegment* CSmsPduDatabase::GetConcatSegmentLC(CSmsPDU::TSmsPDUType aType, TInt aId, TInt aSegment) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   174
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   175
	const TPtrC8 type(GetConcatTypeL(aType));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   176
	RSmsPduDbIdArray array(type, ETrue);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   177
	CleanupClosePushL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   178
	GetIdsL(array, aId);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   179
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   180
	CSmsPduDbConcatSegment* concat = GetConcatSegmentL(array, aType, aId, aSegment);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   181
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   182
	CleanupStack::PopAndDestroy(&array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   183
	CleanupStack::PushL(concat);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   184
	return concat;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   185
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   186
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   187
CSmsPduDbConcatSegment* CSmsPduDatabase::GetConcatSegmentL(const RSmsPduDbIdArray& aIdArray, CSmsPDU::TSmsPDUType aType, TInt aId, TInt aSegment) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   188
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   189
	const TInt count = aIdArray.Count();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   190
	CSmsPduDbConcatSegment* concat = NULL;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   191
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   192
	for (TInt i = 0; i < count; i++) //order important
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   193
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   194
		const TSmsPduDbId& id = aIdArray[i];
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   195
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   196
		if (id.iId == aId)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   197
			{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   198
			const TDesC8& val = id.iItem->Value();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   199
			TInt segment = KErrNotFound;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   200
			const TInt err = CTestConfig::GetElement(val, KSmsPduDbDelimiter, CSmsPduDbConcatSegment::EConcatSegment, segment);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   201
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   202
			if (err == KErrNone && segment == aSegment)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   203
				{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   204
				concat = CSmsPduDbConcatSegment::NewL(iFs, *id.iItem, aType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   205
				break;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   206
				}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   207
			}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   208
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   209
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   210
	if (concat == NULL)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   211
		User::Leave(KErrNotFound);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   212
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   213
	return concat;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   214
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   215
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   216
EXPORT_C CSmsPduDbConcat* CSmsPduDatabase::GetConcatLC(CSmsPDU::TSmsPDUType aType, TInt aId) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   217
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   218
	const TPtrC8 type(GetConcatTypeL(aType));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   219
	RSmsPduDbIdArray array(type, ETrue);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   220
	CleanupClosePushL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   221
	GetIdsL(array, aId);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   222
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   223
	CSmsPduDbConcat* concat = new (ELeave) CSmsPduDbConcat();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   224
	CleanupStack::PushL(concat);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   225
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   226
	const TInt count = array.Count();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   227
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   228
	for (TInt i=0; i<count; i++)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   229
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   230
		const TSmsPduDbId& id = array[i];
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   231
		CSmsPduDbConcatSegment* concatSegment = CSmsPduDbConcatSegment::NewL(iFs, *id.iItem, aType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   232
		CleanupStack::PushL(concatSegment);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   233
		User::LeaveIfError(concat->iSegments.Append(concatSegment));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   234
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   235
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   236
	concat->DecodeL(iFs);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   237
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   238
	CleanupStack::PopAndDestroy(&array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   239
	return concat;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   240
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   241
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   242
EXPORT_C void CSmsPduDatabase::GetConcatL(RPointerArray<CSmsPduDbConcat>& aArray, CSmsPDU::TSmsPDUType aType) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   243
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   244
	const TPtrC8 type(GetConcatTypeL(aType));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   245
	RSmsPduDbIdArray array(type, ETrue);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   246
	CleanupClosePushL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   247
	GetIdsL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   248
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   249
	const TInt count = array.Count();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   250
	TInt lastId = KErrNotFound;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   251
	CSmsPduDbConcat* concat = NULL;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   252
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   253
	for (TInt i=0; i<count; i++)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   254
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   255
		const CTestConfigItem& item = *array[i].iItem;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   256
		const TInt id = array[i].iId;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   257
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   258
		if (id != lastId || concat == NULL)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   259
			{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   260
			if (concat != NULL)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   261
				concat->DecodeL(iFs);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   262
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   263
			concat = new (ELeave) CSmsPduDbConcat();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   264
			CleanupStack::PushL(concat);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   265
			User::LeaveIfError(aArray.Append(concat));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   266
			CleanupStack::Pop(concat);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   267
			lastId = id;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   268
			}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   269
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   270
		CSmsPduDbConcatSegment* segment = CSmsPduDbConcatSegment::NewL(iFs, item, aType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   271
		CleanupStack::PushL(segment);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   272
		User::LeaveIfError(concat->iSegments.Append(segment));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   273
		CleanupStack::Pop(segment);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   274
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   275
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   276
	if (concat != NULL)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   277
		concat->DecodeL(iFs);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   278
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   279
	CleanupStack::PopAndDestroy(&array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   280
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   281
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   282
EXPORT_C CSmsPduDbMessage* CSmsPduDatabase::GetMessageLC(CSmsPDU::TSmsPDUType aType, TInt aId) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   283
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   284
	RSmsPduDbIdArray array(KSmsPduDbMessage);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   285
	CleanupClosePushL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   286
	GetIdsL(array, aId);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   287
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   288
	const CTestConfigItem& item = *array[0].iItem;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   289
	CSmsPduDbMessage* pdu = CSmsPduDbMessage::NewL(iFs, item, aType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   290
	CleanupStack::PushL(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   291
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   292
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   293
	CleanupStack::PopAndDestroy(&array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   294
	return pdu;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   295
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   296
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   297
EXPORT_C void CSmsPduDatabase::GetMessageL(RPointerArray<CSmsPduDbMessage>& aArray, CSmsPDU::TSmsPDUType aType) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   298
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   299
	RSmsPduDbIdArray array(KSmsPduDbMessage);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   300
	CleanupClosePushL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   301
	GetIdsL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   302
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   303
	const TInt count = array.Count();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   304
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   305
	for (TInt i=0; i<count; i++)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   306
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   307
		const CTestConfigItem& item = *array[i].iItem;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   308
		CSmsPduDbMessage* pdu = CSmsPduDbMessage::NewL(iFs, item, aType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   309
		CleanupStack::PushL(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   310
		User::LeaveIfError(aArray.Append(pdu));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   311
		CleanupStack::Pop(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   312
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   313
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   314
	CleanupStack::PopAndDestroy(&array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   315
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   316
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   317
CSmsPduDatabase::CSmsPduDatabase(RFs& aFs)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   318
: iFs(aFs)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   319
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   320
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   321
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   322
void CSmsPduDatabase::GetIdsL(RSmsPduDbIdArray& aIds) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   323
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   324
	RPointerArray<const CTestConfigItem> array;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   325
	CleanupClosePushL(array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   326
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   327
	iSection->ItemsL(array, aIds.Type());
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   328
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   329
	const TInt count = array.Count();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   330
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   331
	for (TInt i=0; i<count; i++)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   332
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   333
		TSmsPduDbId item(array[i]);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   334
		const TInt err = CTestConfig::GetElement(item.iItem->Value(), KSmsPduDbDelimiter, CSmsPduDbBase::ESmsPduDbId, item.iId);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   335
		if (err == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   336
			{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   337
			aIds.InsertL(item);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   338
			}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   339
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   340
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   341
	CleanupStack::PopAndDestroy(&array);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   342
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   343
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   344
void CSmsPduDatabase::GetIdsL(RSmsPduDbIdArray& aIds, TInt aId) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   345
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   346
	RSmsPduDbIdArray tempArray(aIds.Type(), ETrue);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   347
	CleanupClosePushL(tempArray);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   348
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   349
	GetIdsL(tempArray);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   350
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   351
	TInt find = KErrNotFound;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   352
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   353
	while ((find = tempArray.Find(aId)) != KErrNotFound)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   354
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   355
		User::LeaveIfError(aIds.Append(tempArray[find]));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   356
		tempArray.Remove(find);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   357
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   358
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   359
	CleanupStack::PopAndDestroy(&tempArray);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   360
	if (aIds.Count() == 0)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   361
		User::Leave(KErrNotFound);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   362
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   363
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   364
void CSmsPduDatabase::ReadFileL(const TDesC& aInputFileName, const TDesC& aInputComponent, CBufFlat& aData) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   365
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   366
	TParse parse;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   367
	User::LeaveIfError(CTestConfig::ResolveFile(iFs, aInputComponent, aInputFileName, parse));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   368
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   369
	RFile file;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   370
	User::LeaveIfError(file.Open(iFs, parse.FullName(), EFileRead));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   371
	CleanupClosePushL(file);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   372
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   373
	TInt size(0);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   374
	User::LeaveIfError(file.Size(size));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   375
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   376
	for (TInt i = 0; i < size; i += KSmsPduDbMaxReadWriteChunk)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   377
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   378
		const TInt readSize = Min(KSmsPduDbMaxReadWriteChunk, size - i);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   379
		TBuf8<KSmsPduDbMaxReadWriteChunk> read;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   380
		User::LeaveIfError(file.Read(read, readSize));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   381
		const TInt pos = aData.Size();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   382
		aData.InsertL(pos, read);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   383
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   384
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   385
	CleanupStack::PopAndDestroy(&file);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   386
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   387
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   388
void CSmsPduDatabase::WriteFileL(const TDesC& aOutputFileName, const CBufFlat& aData) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   389
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   390
	RFile file;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   391
	User::LeaveIfError(file.Replace(iFs, aOutputFileName, EFileWrite));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   392
	CleanupClosePushL(file);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   393
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   394
	const TInt size = aData.Size();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   395
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   396
	for (TInt i = 0; i < size; i += KSmsPduDbMaxReadWriteChunk)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   397
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   398
		const TInt readSize = Min(KSmsPduDbMaxReadWriteChunk, size - i);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   399
		TBuf8<KSmsPduDbMaxReadWriteChunk> read;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   400
		aData.Read(i, read, readSize);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   401
		User::LeaveIfError(file.Write(read));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   402
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   403
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   404
	User::LeaveIfError(file.Flush());
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   405
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   406
	CleanupStack::PopAndDestroy(&file);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   407
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   408
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   409
EXPORT_C void CSmsPduDatabase::RewriteFileL(const TDesC& aInputFileName, const TDesC& aInputComponent, const TDesC& aOutputFileName) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   410
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   411
	CBufFlat* buffer = CBufFlat::NewL(0x100); //< TODO Remove this magic number
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   412
	CleanupStack::PushL(buffer);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   413
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   414
	ReadFileL(aInputFileName, aInputComponent, *buffer);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   415
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   416
	ParseFileL(*buffer);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   417
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   418
	WriteFileL(aOutputFileName, *buffer);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   419
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   420
	CleanupStack::PopAndDestroy(buffer);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   421
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   422
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   423
void CSmsPduDatabase::ParseFileL(CBufFlat& aData) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   424
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   425
	TPtrC8 ptr(aData.Ptr(0));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   426
	TLex8 lex(ptr);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   427
	lex.Mark();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   428
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   429
	while (!lex.Eos())
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   430
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   431
		if (lex.Peek() == KSmsPduDbTagStart)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   432
			{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   433
			ParseTagL(aData, ptr, lex);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   434
			}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   435
		else
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   436
			{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   437
			lex.Inc();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   438
			}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   439
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   440
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   441
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   442
void CSmsPduDatabase::ParseTagL(CBufFlat& aData, TPtrC8& aPtr, TLex8& aLex) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   443
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   444
	const TInt startingPos = aLex.Offset();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   445
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   446
	const TPtrC8 remainder(aLex.Remainder());
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   447
	const TInt locate = remainder.Locate(KSmsPduDbTagEnd);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   448
	TInt err = locate;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   449
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   450
	if (locate != KErrNotFound)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   451
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   452
		aLex.Mark();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   453
		aLex.Inc(locate+1);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   454
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   455
		const TPtrC8 marked(aLex.MarkedToken());
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   456
		CSmsPduDbPdu* pdu = NULL;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   457
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   458
		TRAP(err, pdu = PduFactoryL(marked));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   459
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   460
		if (err == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   461
			{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   462
			CleanupStack::PushL(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   463
			TBuf8<RMobileSmsMessaging::KGsmTpduSize*2> hexPdu;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   464
			pdu->GetHexPdu(hexPdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   465
			aData.Delete(startingPos, marked.Length());
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   466
			aData.InsertL(startingPos, hexPdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   467
			aPtr.Set(aData.Ptr(0));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   468
			aLex = aPtr;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   469
			aLex.Inc(startingPos + pdu->iPdu.Length());
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   470
			CleanupStack::PopAndDestroy(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   471
			}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   472
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   473
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   474
	if (err != KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   475
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   476
		aLex.Inc();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   477
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   478
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   479
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   480
TBool CSmsPduDatabase::IsPdu(const TDesC8& aTag, CSmsPDU::TSmsPDUType& aType) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   481
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   482
	TBool ret = EFalse;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   483
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   484
	if (aTag.CompareF(KSmsPduDbSubmit) == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   485
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   486
		ret = ETrue;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   487
		aType = CSmsPDU::ESmsSubmit;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   488
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   489
	else if (aTag.CompareF(KSmsPduDbDeliver) == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   490
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   491
		ret = ETrue;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   492
		aType = CSmsPDU::ESmsDeliver;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   493
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   494
	else if (aTag.CompareF(KSmsPduDbStatusReport) == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   495
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   496
		ret = ETrue;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   497
		aType = CSmsPDU::ESmsStatusReport;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   498
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   499
	else if (aTag.CompareF(KSmsPduDbCommand) == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   500
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   501
		ret = ETrue;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   502
		aType = CSmsPDU::ESmsCommand;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   503
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   504
	else if (aTag.CompareF(KSmsPduDbSubmitReport) == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   505
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   506
		ret = ETrue;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   507
		aType = CSmsPDU::ESmsSubmitReport;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   508
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   509
	else if (aTag.CompareF(KSmsPduDbDeliverReport) == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   510
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   511
		ret = ETrue;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   512
		aType = CSmsPDU::ESmsDeliverReport;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   513
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   514
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   515
	return ret;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   516
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   517
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   518
TBool CSmsPduDatabase::IsConcatSegment(const TDesC8& aTag, CSmsPDU::TSmsPDUType& aType) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   519
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   520
	TBool ret = EFalse;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   521
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   522
	if (aTag.CompareF(KSmsPduDbSubmitConcat) == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   523
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   524
		ret = ETrue;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   525
		aType = CSmsPDU::ESmsSubmit;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   526
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   527
	else if (aTag.CompareF(KSmsPduDbDeliverConcat) == KErrNone)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   528
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   529
		ret = ETrue;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   530
		aType = CSmsPDU::ESmsDeliver;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   531
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   532
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   533
	return ret;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   534
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   535
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   536
EXPORT_C CSmsPduDbPdu* CSmsPduDatabase::PduFactoryL(const CTestConfigItem& aItem, CSmsPDU::TSmsPDUType aTypeForMessageTags) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   537
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   538
	const TDesC8& type = aItem.Item();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   539
	CSmsPduDbPdu* pdu = NULL;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   540
	CSmsPDU::TSmsPDUType pduType;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   541
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   542
	if (IsPdu(type, pduType))
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   543
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   544
		pdu = CSmsPduDbPdu::NewL(iFs, aItem, pduType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   545
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   546
	else if (IsConcatSegment(type, pduType))
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   547
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   548
		pdu = CSmsPduDbConcatSegment::NewL(iFs, aItem, pduType);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   549
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   550
	else if (IsMessage(type))
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   551
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   552
		pdu = CSmsPduDbMessage::NewL(iFs, aItem, aTypeForMessageTags);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   553
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   554
	else
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   555
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   556
		//Attempt to parse aItem.Value() using the other overload of PduFactoryL()
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   557
		pdu = PduFactoryL(aItem.Value(), aTypeForMessageTags);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   558
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   559
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   560
	__ASSERT_DEBUG(pdu != NULL, PduDbPanic(EPduDbPanicPduNotConstructed));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   561
	return pdu;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   562
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   563
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   564
EXPORT_C CSmsPduDbPdu* CSmsPduDatabase::PduFactoryL(const TDesC8& aTag, CSmsPDU::TSmsPDUType aTypeForMessageTags) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   565
/**
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   566
 *  Parses tags of the form <MESSAGE_TYPE; ID; {SEGMENT}>, e.g. <SUBMIT,21> or <MESSAGE,2> or <SUBMITCONCAT; 32; 2>
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   567
 *  If the MESSAGE_TYPE and ID combination if found in the PDU database then a CSmsPduDbPdu-derived object is created.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   568
 *  SEGMENT is only compulsory if MESSAGE_TYPE is a concatenated message.
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   569
 *  
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   570
 *  @param aTag Tag of the form <MESSAGE_TYPE; ID; {SEGMENT}>. MESSAGE_TYPE and ID are compulsory and must be delimited by a semicolon (;)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   571
 *  @param aTypeForMessageTags PDU Type used when creating a CSmsPduDbMessage. This occurs if MESSAGE_TYPE == "message"
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   572
 */
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   573
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   574
	TPtrC8 tag(CTestConfig::Trim(aTag));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   575
	const TInt len = tag.Length();
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   576
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   577
	if (len < 4)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   578
		User::Leave(KErrBadName);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   579
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   580
	TInt midStart = 0;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   581
	TInt midLen = len;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   582
	if (tag[0] == KSmsPduDbTagStart)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   583
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   584
		midStart++;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   585
		midLen--;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   586
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   587
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   588
	if (tag[len-1] == KSmsPduDbTagEnd)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   589
		midLen--;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   590
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   591
	tag.Set(tag.Mid(midStart, midLen));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   592
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   593
	TPtrC8 type;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   594
	TInt id(0);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   595
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   596
	User::LeaveIfError(CTestConfig::GetElement(tag, KSmsPduDbTagDelimitier, ETagType, type));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   597
	User::LeaveIfError(CTestConfig::GetElement(tag, KSmsPduDbTagDelimitier, ETagId, id));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   598
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   599
	CSmsPduDbPdu* pdu = NULL;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   600
	CSmsPDU::TSmsPDUType pduType;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   601
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   602
	if (IsPdu(type, pduType))
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   603
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   604
		pdu = GetPduLC(pduType, id);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   605
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   606
	else if (IsConcatSegment(type, pduType))
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   607
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   608
		TInt segment;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   609
		User::LeaveIfError(CTestConfig::GetElement(tag, KSmsPduDbTagDelimitier, ETagSegment, segment));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   610
		pdu = GetConcatSegmentLC(pduType, id, segment);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   611
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   612
	else if (IsMessage(type))
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   613
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   614
		pdu = GetMessageLC(aTypeForMessageTags, id);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   615
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   616
	else
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   617
		{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   618
		User::Leave(KErrBadName);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   619
		}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   620
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   621
	__ASSERT_DEBUG(pdu != NULL, PduDbPanic(EPduDbPanicPduNotConstructed));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   622
	CleanupStack::Pop(pdu);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   623
	return pdu;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   624
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   625
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   626
EXPORT_C CSmsPduDbPdu* CSmsPduDatabase::PduFactory(const TDesC8& aTag, CSmsPDU::TSmsPDUType aTypeForMessageTags) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   627
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   628
	CSmsPduDbPdu* pdu = NULL;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   629
	TRAPD(err, (pdu = PduFactoryL(aTag, aTypeForMessageTags)));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   630
	return ((err == KErrNone) ? pdu : NULL);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   631
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   632
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   633
EXPORT_C CSmsPduDbPdu* CSmsPduDatabase::PduFactory(const CTestConfigItem& aItem, CSmsPDU::TSmsPDUType aTypeForMessageTags) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   634
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   635
	CSmsPduDbPdu* pdu = NULL;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   636
	TRAPD(err, (pdu = PduFactoryL(aItem, aTypeForMessageTags)));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   637
	return ((err == KErrNone) ? pdu : NULL);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   638
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   639
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   640
TInt CSmsPduDatabase::RSmsPduDbIdArray::Compare(const TSmsPduDbId& aLeft, const TSmsPduDbId& aRight)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   641
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   642
	return aLeft.iId - aRight.iId;
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   643
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   644
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   645
TInt CSmsPduDatabase::RSmsPduDbIdArray::Find(TInt aId) const
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   646
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   647
	TLinearOrder<TSmsPduDbId> order(Compare);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   648
	const TSmsPduDbId tempId(NULL, aId);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   649
	return FindInOrder(tempId, order);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   650
	}
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   651
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   652
void CSmsPduDatabase::RSmsPduDbIdArray::InsertL(const TSmsPduDbId& aId)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   653
	{
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   654
	TLinearOrder<TSmsPduDbId> order(Compare);
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   655
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   656
	if (iAllowDuplicates)
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   657
		User::LeaveIfError(InsertInOrderAllowRepeats(aId, order));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   658
	else
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   659
		User::LeaveIfError(InsertInOrder(aId, order));
6638e7f4bd8f opencode
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents: 0
diff changeset
   660
	}