|
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 <sysutil.h> |
|
17 |
|
18 #include "cgmrcommandhandler.h" |
|
19 |
|
20 #include "atmisccmdpluginconsts.h" |
|
21 #include "debug.h" |
|
22 |
|
23 CCGMRCommandHandler* CCGMRCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) |
|
24 { |
|
25 TRACE_FUNC_ENTRY |
|
26 CCGMRCommandHandler* self = new (ELeave) CCGMRCommandHandler(aCallback, aATCmdParser, aPhone); |
|
27 CleanupStack::PushL(self); |
|
28 self->ConstructL(); |
|
29 CleanupStack::Pop(self); |
|
30 TRACE_FUNC_EXIT |
|
31 return self; |
|
32 } |
|
33 |
|
34 CCGMRCommandHandler::CCGMRCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : |
|
35 CATCmdSyncBase(aCallback, aATCmdParser, aPhone) |
|
36 { |
|
37 TRACE_FUNC_ENTRY |
|
38 TRACE_FUNC_EXIT |
|
39 } |
|
40 |
|
41 void CCGMRCommandHandler::ConstructL() |
|
42 { |
|
43 TRACE_FUNC_ENTRY |
|
44 iReply.CreateL(KDefaultCmdBufLength); |
|
45 TRACE_FUNC_EXIT |
|
46 } |
|
47 |
|
48 CCGMRCommandHandler::~CCGMRCommandHandler() |
|
49 { |
|
50 TRACE_FUNC_ENTRY |
|
51 iReply.Close(); |
|
52 TRACE_FUNC_EXIT |
|
53 } |
|
54 |
|
55 void CCGMRCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/) |
|
56 { |
|
57 TRACE_FUNC_ENTRY |
|
58 |
|
59 TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); |
|
60 |
|
61 switch (cmdHandlerType) |
|
62 { |
|
63 case (TAtCommandParser::ECmdHandlerTypeTest): |
|
64 { |
|
65 iCallback->CreateReplyAndComplete( EReplyTypeOk ); |
|
66 break; |
|
67 } |
|
68 case (TAtCommandParser::ECmdHandlerTypeBase): |
|
69 { |
|
70 TInt replyType = EReplyTypeOk; |
|
71 if (iReply.Length() == 0) |
|
72 { |
|
73 replyType = GetSoftwareVersion(); |
|
74 } |
|
75 |
|
76 if ( (EReplyTypeOk != replyType) ) |
|
77 { |
|
78 iCallback->CreateCMEReplyAndComplete(KErrUnknown); |
|
79 } |
|
80 else |
|
81 { |
|
82 iCallback->CreateReplyAndComplete( EReplyTypeOk, iReply); |
|
83 } |
|
84 break; |
|
85 } |
|
86 default: |
|
87 { |
|
88 iCallback->CreateReplyAndComplete(EReplyTypeError); |
|
89 break; |
|
90 } |
|
91 } |
|
92 TRACE_FUNC_EXIT |
|
93 } |
|
94 |
|
95 TInt CCGMRCommandHandler::GetSoftwareVersion() |
|
96 { |
|
97 TRACE_FUNC_ENTRY |
|
98 iReply.Append( KCRLF ); |
|
99 |
|
100 // Get software version (e.g. 010.009) |
|
101 TBuf<KSysUtilVersionTextLength> swVersion; |
|
102 TInt errorCode = SysUtil::GetSWVersion( swVersion ); |
|
103 |
|
104 if (KErrNone == errorCode) |
|
105 { |
|
106 TLex8 lex(swVersion.Collapse()); |
|
107 lex.SkipCharacters(); |
|
108 TPtrC8 token = lex.MarkedToken(); |
|
109 iReply.Append(token); |
|
110 |
|
111 iReply.Append( KCRLF ); |
|
112 TRACE_FUNC_EXIT |
|
113 return EReplyTypeOk; |
|
114 } |
|
115 else |
|
116 { |
|
117 TRACE_FUNC_EXIT |
|
118 return EReplyTypeError; |
|
119 } |
|
120 } |
|
121 |
|
122 |
|
123 |