0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "T_ParsePtrCData.h"
|
|
19 |
|
|
20 |
|
|
21 |
// Commands
|
|
22 |
_LIT( KCmdDelete, "~" );
|
|
23 |
_LIT( KCmdNew, "new" );
|
|
24 |
_LIT( KCmdAddDir, "AddDir");
|
|
25 |
_LIT( KCmdPopDir, "PopDir");
|
|
26 |
|
|
27 |
// Parameters
|
|
28 |
_LIT( KParamFileName, "FileName" );
|
|
29 |
_LIT( KParamDirName, "DirName" );
|
|
30 |
|
|
31 |
|
|
32 |
CT_ParsePtrCData* CT_ParsePtrCData::NewL()
|
|
33 |
/**
|
|
34 |
* Two phase constructor
|
|
35 |
*/
|
|
36 |
{
|
|
37 |
CT_ParsePtrCData* ret = new (ELeave) CT_ParsePtrCData();
|
|
38 |
CleanupStack::PushL( ret );
|
|
39 |
ret->ConstructL();
|
|
40 |
CleanupStack::Pop( ret );
|
|
41 |
return ret;
|
|
42 |
}
|
|
43 |
|
|
44 |
CT_ParsePtrCData::CT_ParsePtrCData()
|
|
45 |
: iParsePtrC(NULL)
|
|
46 |
/**
|
|
47 |
* Protected constructor. First phase construction
|
|
48 |
*/
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
void CT_ParsePtrCData::ConstructL()
|
|
53 |
/**
|
|
54 |
* Protected constructor. Second phase construction
|
|
55 |
*/
|
|
56 |
{
|
|
57 |
}
|
|
58 |
|
|
59 |
CT_ParsePtrCData::~CT_ParsePtrCData()
|
|
60 |
/**
|
|
61 |
* Destructor.
|
|
62 |
*/
|
|
63 |
{
|
|
64 |
DoCleanup();
|
|
65 |
}
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
TParseBase* CT_ParsePtrCData::GetParse()
|
|
70 |
{
|
|
71 |
return iParsePtrC;
|
|
72 |
}
|
|
73 |
|
|
74 |
TBool CT_ParsePtrCData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
|
75 |
/**
|
|
76 |
* Process a command read from the ini file
|
|
77 |
*
|
|
78 |
* @param aCommand the command to process
|
|
79 |
* @param aSection the entry in the ini file requiring the command to be processed
|
|
80 |
*
|
|
81 |
* @return ETrue if the command is processed
|
|
82 |
*/
|
|
83 |
{
|
|
84 |
TBool retVal = ETrue;
|
|
85 |
|
|
86 |
if ( aCommand == KCmdDelete )
|
|
87 |
{
|
|
88 |
DoCleanup();
|
|
89 |
}
|
|
90 |
else if ( aCommand == KCmdNew )
|
|
91 |
{
|
|
92 |
DoCmdNew( aSection );
|
|
93 |
}
|
|
94 |
else if ( aCommand == KCmdAddDir )
|
|
95 |
{
|
|
96 |
DoCmdAddDir( aSection );
|
|
97 |
}
|
|
98 |
else if ( aCommand == KCmdPopDir )
|
|
99 |
{
|
|
100 |
DoCmdPopDir();
|
|
101 |
}
|
|
102 |
else
|
|
103 |
{
|
|
104 |
retVal = CT_ParseBaseData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
|
|
105 |
}
|
|
106 |
|
|
107 |
return retVal;
|
|
108 |
}
|
|
109 |
|
|
110 |
void CT_ParsePtrCData::DoCleanup()
|
|
111 |
/** Deletes TParsePtr class instance */
|
|
112 |
{
|
|
113 |
INFO_PRINTF1( _L( "Delete TParsePtrC class instance." ) );
|
|
114 |
|
|
115 |
delete iParsePtrC;
|
|
116 |
iParsePtrC = NULL;
|
|
117 |
}
|
|
118 |
|
|
119 |
void CT_ParsePtrCData::DoCmdNew( const TDesC& aSection )
|
|
120 |
/** Creates new TParsePtr class instance */
|
|
121 |
{
|
|
122 |
DoCleanup();
|
|
123 |
|
|
124 |
TPtrC fileName;
|
|
125 |
if ( GET_MANDATORY_STRING_PARAMETER( KParamFileName, aSection, fileName ) )
|
|
126 |
{
|
|
127 |
INFO_PRINTF2( _L( "Create new TParsePtrC(\"%S\") class instance." ), &fileName );
|
|
128 |
|
|
129 |
iFileName = fileName;
|
|
130 |
TRAPD( err, iParsePtrC = new (ELeave) TParsePtrC( iFileName ) );
|
|
131 |
if ( err != KErrNone )
|
|
132 |
{
|
|
133 |
ERR_PRINTF3( _L( "new TParsePtrC(\"%S\") error=%d" ), &fileName, err );
|
|
134 |
SetError( err );
|
|
135 |
}
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
|
|
140 |
void CT_ParsePtrCData::DoCmdPopDir()
|
|
141 |
/** Removes the last directory from the path using PopDir(). */
|
|
142 |
{
|
|
143 |
INFO_PRINTF1( _L( "PopDir()" ) );
|
|
144 |
|
|
145 |
TInt err = iParsePtrC->PopDir();
|
|
146 |
|
|
147 |
if( err != KErrNone)
|
|
148 |
{
|
|
149 |
ERR_PRINTF2( _L( "PopDir() returned %d error"), err);
|
|
150 |
SetError(err);
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
|
|
155 |
void CT_ParsePtrCData::DoCmdAddDir( const TDesC& aSection )
|
|
156 |
/** Adds a single directory onto the end of the path using AddDir. */
|
|
157 |
{
|
|
158 |
TPtrC dirName;
|
|
159 |
if ( GET_MANDATORY_STRING_PARAMETER( KParamDirName, aSection, dirName ) )
|
|
160 |
{
|
|
161 |
INFO_PRINTF2( _L( "AddDir(\"%S\")" ), &dirName );
|
|
162 |
|
|
163 |
TInt err = iParsePtrC->AddDir( dirName );
|
|
164 |
if( err != KErrNone)
|
|
165 |
{
|
|
166 |
ERR_PRINTF2( _L( "AddDir() returned %d error"), err);
|
|
167 |
SetError(err);
|
|
168 |
}
|
|
169 |
}
|
|
170 |
}
|
|
171 |
|