|
1 // Copyright (c) 2002-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 // $Header$ |
|
15 // rev: mjdavey, symbian@mjdss.com, July 2002 |
|
16 // for: Typhoon (7.0s) & JetStream (8.0) |
|
17 // This module implements the CCmdLog (log mode) command class. |
|
18 // |
|
19 // |
|
20 |
|
21 #include "CCmdLog.h" |
|
22 |
|
23 //----------------------------------------------------------------------------- |
|
24 |
|
25 CCmdLog *CCmdLog::NewL(TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
26 { |
|
27 CCmdLog *self = NewLC( aCommandId, aKeyphrase, aHelpPhrase); |
|
28 CleanupStack::Pop(); |
|
29 return self; |
|
30 } |
|
31 |
|
32 //----------------------------------------------------------------------------- |
|
33 |
|
34 CCmdLog *CCmdLog::NewLC( TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
35 { |
|
36 CCmdLog *self = new (ELeave) CCmdLog(); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(aCommandId, aKeyphrase, aHelpPhrase); |
|
39 return self; |
|
40 } |
|
41 |
|
42 //----------------------------------------------------------------------------- |
|
43 |
|
44 void CCmdLog::ConstructL( TInt aCommandId, const TDesC& aKeyphrase, const TDesC& aHelpPhrase) |
|
45 { |
|
46 CCmdBase::ConstructL(aCommandId, aKeyphrase, aHelpPhrase); |
|
47 } |
|
48 |
|
49 //----------------------------------------------------------------------------- |
|
50 // LOG sets controls on logging of input/output |
|
51 // |
|
52 // LOG ALL sets comments, commands and cases to ON |
|
53 // LOG NONE resets all comment options to OFF |
|
54 // LOG [COMMENTS | COMMANDS | CASES] will enable the appropriate subclass |
|
55 |
|
56 TInt CCmdLog::ProcessL( const TDesC& aCommand ) |
|
57 { |
|
58 TPtrC param; |
|
59 TRAPD( error, param.Set(ParamsL(aCommand))); |
|
60 if ( error != KErrNone ) |
|
61 return Error(error, KFmtErrInvalidCmd, &Keyphrase()); |
|
62 |
|
63 TBool logComments = EFalse; |
|
64 TBool logCommands = EFalse; |
|
65 TBool logCases = EFalse; |
|
66 param.Set( TfrLex::Trim( param ) ); |
|
67 if ( param.CompareF(KTxtLogALL) == 0 ) |
|
68 { |
|
69 logComments = ETrue; |
|
70 logCommands = ETrue; |
|
71 logCases = ETrue; |
|
72 } |
|
73 else if (param.CompareF(KTxtLogNONE) == 0) |
|
74 { |
|
75 logComments = EFalse; |
|
76 logCommands = EFalse; |
|
77 logCases = EFalse; |
|
78 } |
|
79 else if (param.Length() == 0) |
|
80 error = KErrArgument; |
|
81 else |
|
82 { |
|
83 TLex parse(param); |
|
84 parse.SkipSpace(); |
|
85 while (!parse.Eos()) |
|
86 { |
|
87 if (TfrLex::ValF(parse,KTxtLogCOMMENTS) == KErrNone) |
|
88 logComments = ETrue; |
|
89 else if (TfrLex::ValF(parse,KTxtLogCOMMANDS) == KErrNone) |
|
90 logCommands = ETrue; |
|
91 else if (TfrLex::ValF(parse,KTxtLogCASES) == KErrNone) |
|
92 logCases = ETrue; |
|
93 else |
|
94 { |
|
95 error = KErrArgument; |
|
96 break; |
|
97 } |
|
98 |
|
99 parse.SkipSpace(); |
|
100 |
|
101 if ( !parse.Eos() && parse.Get() != ',' ) |
|
102 { |
|
103 error = KErrArgument; |
|
104 break; |
|
105 } |
|
106 |
|
107 parse.SkipSpace(); |
|
108 } |
|
109 } |
|
110 |
|
111 if ( error != KErrNone ) |
|
112 return Error(error, KFmtErrInvalidCmd, &Keyphrase()); |
|
113 |
|
114 // now set the flag in each command case |
|
115 TInt i; |
|
116 CCmdBase* cmd; |
|
117 for ( i = 0; i < Family()->Count(); i++ ) |
|
118 { |
|
119 cmd = Family()->At(i); |
|
120 if (cmd->CommandId() == THA_KCmdRemark ) |
|
121 cmd->SetFlag(CCmdBase::EDoLog, logComments); |
|
122 |
|
123 else if (cmd->CommandId() == ECase ) |
|
124 cmd->SetFlag(CCmdBase::EDoLog, logCases); |
|
125 |
|
126 else |
|
127 cmd->SetFlag(CCmdBase::EDoLog, logCommands); |
|
128 } |
|
129 |
|
130 return error; |
|
131 } |
|
132 |
|
133 //----------------------------------------------------------------------------- |
|
134 // End of File |
|
135 //----------------------------------------------------------------------------- |
|
136 |