24
|
1 |
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// Contains the definition of CSmsPduDatabase and a description of the database and tag format
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
@internalComponent
|
|
21 |
*/
|
|
22 |
|
|
23 |
#ifndef __SMS_PDU_DB_H__
|
|
24 |
#define __SMS_PDU_DB_H__
|
|
25 |
|
|
26 |
#include "smspdudbitems.h"
|
|
27 |
#include "smsstackutils.h"
|
|
28 |
|
|
29 |
class CTestConfig;
|
|
30 |
class CTestConfigSection;
|
|
31 |
|
|
32 |
_LIT8(KSmsPduDbDefaultSection, "db");
|
|
33 |
_LIT(KSmsPduDbDefaultFilename, "smspdudb.txt");
|
|
34 |
_LIT(KSmsPduDbDefaultComponent, "sms");
|
|
35 |
|
|
36 |
class CSmsPduDatabase : public CBase
|
|
37 |
/**
|
|
38 |
* CSmsPduDatabase can read a SMS PDU database file and return the desired PDU or Message. This class can also parse CConfigTestItem's and special tags in its PduFactoryL() functions.
|
|
39 |
*/
|
|
40 |
{
|
|
41 |
private:
|
|
42 |
|
|
43 |
enum TSmsPduDbTag
|
|
44 |
/**
|
|
45 |
* Position of elements in special tag that specifies an item in the PDU database
|
|
46 |
* Has the format <[MESSAGE_TYPE]; [ID]; {SEGMENT}>. See PduFactoryL(const TDesC&) for more information.
|
|
47 |
*/
|
|
48 |
{
|
|
49 |
ETagType = 0, //< 1st element, alphanumeric. E.g. submit
|
|
50 |
ETagId, //< 2nd element, integer
|
|
51 |
ETagSegment //< 3rd element, optional integer
|
|
52 |
};
|
|
53 |
|
|
54 |
class TSmsPduDbId
|
|
55 |
/**
|
|
56 |
* Used internally within CSmsPduDatabase for quickly parsing the CTestConfig and obtaining an array of CConfigTestItem and ID pairs.
|
|
57 |
*/
|
|
58 |
{
|
|
59 |
public:
|
|
60 |
|
|
61 |
inline TSmsPduDbId(const CTestConfigItem* aItem=NULL, TInt aId=0);
|
|
62 |
|
|
63 |
public:
|
|
64 |
|
|
65 |
const CTestConfigItem* iItem;
|
|
66 |
TInt iId;
|
|
67 |
};
|
|
68 |
|
|
69 |
class RSmsPduDbIdArray : public RArray<TSmsPduDbId>
|
|
70 |
{
|
|
71 |
public:
|
|
72 |
|
|
73 |
inline RSmsPduDbIdArray(const TDesC8& aType, TBool aAllowDuplicates=EFalse);
|
|
74 |
TInt Find(TInt aId) const;
|
|
75 |
void InsertL(const TSmsPduDbId& aId);
|
|
76 |
inline const TDesC8& Type() const;
|
|
77 |
|
|
78 |
private:
|
|
79 |
|
|
80 |
static TInt Compare(const TSmsPduDbId& aLeft, const TSmsPduDbId& aRight);
|
|
81 |
|
|
82 |
private:
|
|
83 |
|
|
84 |
const TDesC8& iType;
|
|
85 |
TBool iAllowDuplicates;
|
|
86 |
};
|
|
87 |
|
|
88 |
public:
|
|
89 |
|
|
90 |
IMPORT_C static CSmsPduDatabase* NewL(RFs& aFs); //< Uses section=KSmsPduDbDefaultSection, fileName=KSmsPduDbDefaultFilename, component=KSmsPduDbDefaultComponent
|
|
91 |
IMPORT_C static CSmsPduDatabase* NewL(RFs& aFs, const TDesC8& aSection, const TDesC& aFileName, const TDesC& aComponent);
|
|
92 |
IMPORT_C static CSmsPduDatabase* NewL(RFs& aFs, const CTestConfigSection& aSection);
|
|
93 |
|
|
94 |
IMPORT_C ~CSmsPduDatabase();
|
|
95 |
|
|
96 |
IMPORT_C CSmsPduDbPdu* GetPduLC(CSmsPDU::TSmsPDUType aType, TInt aId) const;
|
|
97 |
IMPORT_C CSmsPduDbConcatSegment* GetConcatSegmentLC(CSmsPDU::TSmsPDUType aType, TInt aId, TInt aSegment) const;
|
|
98 |
IMPORT_C CSmsPduDbConcat* GetConcatLC(CSmsPDU::TSmsPDUType aType, TInt aId) const;
|
|
99 |
IMPORT_C CSmsPduDbMessage* GetMessageLC(CSmsPDU::TSmsPDUType aType, TInt aId) const;
|
|
100 |
|
|
101 |
IMPORT_C void GetPduL(RPointerArray<CSmsPduDbPdu>& aArray, CSmsPDU::TSmsPDUType aType) const;
|
|
102 |
IMPORT_C void GetConcatL(RPointerArray<CSmsPduDbConcat>& aArray, CSmsPDU::TSmsPDUType aType) const;
|
|
103 |
IMPORT_C void GetMessageL(RPointerArray<CSmsPduDbMessage>& aArray, CSmsPDU::TSmsPDUType aType) const;
|
|
104 |
|
|
105 |
IMPORT_C void RewriteFileL(const TDesC& aInputFileName, const TDesC& aInputComponent, const TDesC& aOutputFileName) const; //< Rewrites the SIM TSY config.txt using items in this PDU Database
|
|
106 |
|
|
107 |
IMPORT_C CSmsPduDbPdu* PduFactoryL(const TDesC8& aTag, CSmsPDU::TSmsPDUType aTypeForMessageTags = CSmsPDU::ESmsSubmit) const;
|
|
108 |
IMPORT_C CSmsPduDbPdu* PduFactory(const TDesC8& aTag, CSmsPDU::TSmsPDUType aTypeForMessageTags = CSmsPDU::ESmsSubmit) const;
|
|
109 |
|
|
110 |
IMPORT_C CSmsPduDbPdu* PduFactoryL(const CTestConfigItem& aItem, CSmsPDU::TSmsPDUType aTypeForMessageTags = CSmsPDU::ESmsSubmit) const;
|
|
111 |
IMPORT_C CSmsPduDbPdu* PduFactory(const CTestConfigItem& aItem, CSmsPDU::TSmsPDUType aTypeForMessageTags = CSmsPDU::ESmsSubmit) const;
|
|
112 |
|
|
113 |
inline CTestConfig& ConfigFile();
|
|
114 |
inline const CTestConfig& ConfigFile() const;
|
|
115 |
inline void SetSectionL(const TDesC8& aSection);
|
|
116 |
inline void SetSection(const CTestConfigSection& aSection);
|
|
117 |
|
|
118 |
private:
|
|
119 |
|
|
120 |
CSmsPduDatabase(RFs& aFs);
|
|
121 |
|
|
122 |
void GetIdsL(RSmsPduDbIdArray& aIds, TInt aId) const;
|
|
123 |
void GetIdsL(RSmsPduDbIdArray& aIds) const;
|
|
124 |
TPtrC8 GetTypeL(CSmsPDU::TSmsPDUType aType) const;
|
|
125 |
|
|
126 |
TPtrC8 GetConcatTypeL(CSmsPDU::TSmsPDUType aType) const;
|
|
127 |
CSmsPduDbConcatSegment* GetConcatSegmentL(const RSmsPduDbIdArray& aIdArray, CSmsPDU::TSmsPDUType aType, TInt aId, TInt aSegment) const;
|
|
128 |
|
|
129 |
void ReadFileL(const TDesC& aInputFileName, const TDesC& aInputComponent, CBufFlat& aData) const;
|
|
130 |
void WriteFileL(const TDesC& aOutputFileName, const CBufFlat& aData) const;
|
|
131 |
void ParseFileL(CBufFlat& aData) const;
|
|
132 |
void ParseTagL(CBufFlat& aData, TPtrC8& aPtr, TLex8& aLex) const;
|
|
133 |
|
|
134 |
TBool IsPdu(const TDesC8& aTag, CSmsPDU::TSmsPDUType& aType) const;
|
|
135 |
TBool IsConcatSegment(const TDesC8& aTag, CSmsPDU::TSmsPDUType& aType) const;
|
|
136 |
inline TBool IsMessage(const TDesC8& aTag) const;
|
|
137 |
|
|
138 |
private:
|
|
139 |
|
|
140 |
RFs& iFs;
|
|
141 |
CTestConfig* iConfigFile;
|
|
142 |
const CTestConfigSection* iSection; //< Owned by iConfigFile
|
|
143 |
};
|
|
144 |
|
|
145 |
_LIT(KSmsPduDbPanic, "SmsPduDatabase");
|
|
146 |
enum TSmsPduDbPanic
|
|
147 |
{
|
|
148 |
EPduDbPanicConfigFileNotConstructed,
|
|
149 |
EPduDbPanicPduNotConstructed
|
|
150 |
};
|
|
151 |
|
|
152 |
inline void PduDbPanic(TSmsPduDbPanic);
|
|
153 |
|
|
154 |
#include "smspdudb.inl"
|
|
155 |
|
|
156 |
#endif
|