1 /* |
|
2 * Copyright (c) 2010 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 "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 * Initial Contributors: |
|
9 * Nokia Corporation - initial contribution. |
|
10 * |
|
11 * Contributors: |
|
12 * Description : |
|
13 * |
|
14 */ |
|
15 |
|
16 #include "hvercommandhandler.h" |
|
17 #include <sysutil.h> |
|
18 |
|
19 #include "atmisccmdpluginconsts.h" |
|
20 #include "debug.h" |
|
21 |
|
22 const TUint KCommaValue = 44; |
|
23 const TUint KSpaceValue = 32; |
|
24 |
|
25 CHVERCommandHandler* CHVERCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) |
|
26 { |
|
27 TRACE_FUNC_ENTRY |
|
28 CHVERCommandHandler* self = new (ELeave) CHVERCommandHandler(aCallback, aATCmdParser, aPhone); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 TRACE_FUNC_EXIT |
|
33 return self; |
|
34 } |
|
35 |
|
36 CHVERCommandHandler::CHVERCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : |
|
37 CATCmdSyncBase(aCallback, aATCmdParser, aPhone) |
|
38 { |
|
39 TRACE_FUNC_ENTRY |
|
40 TRACE_FUNC_EXIT |
|
41 } |
|
42 |
|
43 void CHVERCommandHandler::ConstructL() |
|
44 { |
|
45 TRACE_FUNC_ENTRY |
|
46 iTelError = KErrNone; |
|
47 iSWVersion.CreateL(KSysUtilVersionTextLength); |
|
48 iReply.CreateL(KDefaultCmdBufLength); |
|
49 TRACE_FUNC_EXIT |
|
50 } |
|
51 |
|
52 CHVERCommandHandler::~CHVERCommandHandler() |
|
53 { |
|
54 TRACE_FUNC_ENTRY |
|
55 iSWVersion.Close(); |
|
56 iReply.Close(); |
|
57 TRACE_FUNC_EXIT |
|
58 } |
|
59 |
|
60 void CHVERCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/) |
|
61 { |
|
62 TRACE_FUNC_ENTRY |
|
63 |
|
64 TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); |
|
65 |
|
66 if (cmdHandlerType != TAtCommandParser::ECmdHandlerTypeBase) |
|
67 { |
|
68 iCallback->CreateReplyAndComplete(EReplyTypeError); |
|
69 } |
|
70 else if(iTelError == KErrNone) |
|
71 { |
|
72 if (iReply.Length() == 0) |
|
73 { |
|
74 // Get model |
|
75 iReply.Append( KCRLF ); |
|
76 iReply.Append( iModel ); |
|
77 |
|
78 TChar commaValue = KCommaValue; |
|
79 TChar spaceValue = KSpaceValue; |
|
80 iReply.Append( commaValue ); |
|
81 iReply.Append( spaceValue ); |
|
82 |
|
83 // Get software version (RM-xxx) |
|
84 TBuf<KSysUtilVersionTextLength> swVersion; |
|
85 TInt errorCode = SysUtil::GetSWVersion( swVersion ); |
|
86 |
|
87 if (KErrNone == errorCode) |
|
88 { |
|
89 ParseSWVersion(swVersion.Collapse()); |
|
90 iReply.Append(iSWVersion); |
|
91 } |
|
92 iReply.Append( KCRLF ); |
|
93 } |
|
94 iCallback->CreateReplyAndComplete( EReplyTypeOk, iReply); |
|
95 } |
|
96 else |
|
97 { |
|
98 iCallback->CreateCMEReplyAndComplete(iTelError); |
|
99 } |
|
100 |
|
101 TRACE_FUNC_EXIT |
|
102 } |
|
103 |
|
104 void CHVERCommandHandler::ParseSWVersion(const TDesC8& aSWVersion) |
|
105 { |
|
106 TRACE_FUNC_ENTRY |
|
107 if (iSWVersion.Length() != 0) |
|
108 { |
|
109 TRACE_FUNC_EXIT |
|
110 return; |
|
111 } |
|
112 |
|
113 TInt start = aSWVersion.Find(KHVERModelString); |
|
114 |
|
115 if ( KErrNotFound != start ) |
|
116 { |
|
117 TLex8 lex(aSWVersion); |
|
118 lex.Inc(start); |
|
119 lex.Mark(); |
|
120 lex.SkipCharacters(); |
|
121 TPtrC8 token = lex.MarkedToken(); |
|
122 |
|
123 iSWVersion.Append(token); |
|
124 } |
|
125 TRACE_FUNC_EXIT |
|
126 } |
|
127 |
|
128 void CHVERCommandHandler::SetHWVersion(const TDesC8& aHWVersion) |
|
129 { |
|
130 TRACE_FUNC_ENTRY |
|
131 iModel.Zero(); |
|
132 if (aHWVersion.Length() <= CTelephony::KPhoneModelIdSize) |
|
133 { |
|
134 iModel.Copy(aHWVersion); |
|
135 } |
|
136 else |
|
137 { |
|
138 iModel.Copy(aHWVersion.Left(CTelephony::KPhoneModelIdSize)); |
|
139 } |
|
140 TRACE_FUNC_EXIT |
|
141 } |
|
142 |
|
143 |
|
144 |
|
145 void CHVERCommandHandler::SetTelephonyError(TInt aTelError) |
|
146 { |
|
147 TRACE_FUNC_ENTRY |
|
148 iTelError = aTelError; |
|
149 TRACE_FUNC_EXIT |
|
150 } |
|
151 |
|