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 "cgmmcommandhandler.h" |
|
17 |
|
18 #include "atmisccmdpluginconsts.h" |
|
19 #include "debug.h" |
|
20 |
|
21 CCGMMCommandHandler* CCGMMCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) |
|
22 { |
|
23 TRACE_FUNC_ENTRY |
|
24 CCGMMCommandHandler* self = new (ELeave) CCGMMCommandHandler(aCallback, aATCmdParser, aPhone); |
|
25 CleanupStack::PushL(self); |
|
26 self->ConstructL(); |
|
27 CleanupStack::Pop(self); |
|
28 TRACE_FUNC_EXIT |
|
29 return self; |
|
30 } |
|
31 |
|
32 CCGMMCommandHandler::CCGMMCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : |
|
33 CATCmdSyncBase(aCallback, aATCmdParser, aPhone) |
|
34 { |
|
35 TRACE_FUNC_ENTRY |
|
36 TRACE_FUNC_EXIT |
|
37 } |
|
38 |
|
39 void CCGMMCommandHandler::ConstructL() |
|
40 { |
|
41 TRACE_FUNC_ENTRY |
|
42 iReply.CreateL(KDefaultCmdBufLength); |
|
43 TRACE_FUNC_EXIT |
|
44 } |
|
45 |
|
46 CCGMMCommandHandler::~CCGMMCommandHandler() |
|
47 { |
|
48 TRACE_FUNC_ENTRY |
|
49 iReply.Close(); |
|
50 TRACE_FUNC_EXIT |
|
51 } |
|
52 |
|
53 void CCGMMCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/) |
|
54 { |
|
55 TRACE_FUNC_ENTRY |
|
56 |
|
57 TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); |
|
58 |
|
59 switch (cmdHandlerType) |
|
60 { |
|
61 case (TAtCommandParser::ECmdHandlerTypeTest): |
|
62 { |
|
63 iCallback->CreateReplyAndComplete( EReplyTypeOk ); |
|
64 break; |
|
65 } |
|
66 case (TAtCommandParser::ECmdHandlerTypeBase): |
|
67 { |
|
68 if(iTelError == KErrNone) |
|
69 { |
|
70 if (iReply.Length() == 0) |
|
71 { |
|
72 _LIT8( KSpace, " " ); |
|
73 |
|
74 iReply.Append( KCRLF ); |
|
75 iReply.Append( iManufacturer ); |
|
76 iReply.Append( KSpace ); |
|
77 iReply.Append( iModel ); |
|
78 iReply.Append( KCRLF ); |
|
79 } |
|
80 |
|
81 iCallback->CreateReplyAndComplete( EReplyTypeOk, iReply); |
|
82 } |
|
83 else |
|
84 { |
|
85 iCallback->CreateCMEReplyAndComplete(iTelError); |
|
86 } |
|
87 break; |
|
88 } |
|
89 default: |
|
90 { |
|
91 iCallback->CreateReplyAndComplete(EReplyTypeError); |
|
92 break; |
|
93 } |
|
94 } |
|
95 |
|
96 TRACE_FUNC_EXIT |
|
97 } |
|
98 |
|
99 void CCGMMCommandHandler::SetManufacturer(const TDesC8& aManufacturer) |
|
100 { |
|
101 TRACE_FUNC_ENTRY |
|
102 iManufacturer.Zero(); |
|
103 if (aManufacturer.Length() <= CTelephony::KPhoneManufacturerIdSize) |
|
104 { |
|
105 iManufacturer.Copy(aManufacturer); |
|
106 } |
|
107 else |
|
108 { |
|
109 iManufacturer.Copy(aManufacturer.Left(CTelephony::KPhoneManufacturerIdSize)); |
|
110 } |
|
111 TRACE_FUNC_EXIT |
|
112 } |
|
113 |
|
114 void CCGMMCommandHandler::SetModelID(const TDesC8& aModelID) |
|
115 { |
|
116 TRACE_FUNC_ENTRY |
|
117 iModel.Zero(); |
|
118 if (aModelID.Length() <= CTelephony::KPhoneModelIdSize) |
|
119 { |
|
120 iModel.Copy(aModelID); |
|
121 } |
|
122 else |
|
123 { |
|
124 iModel.Copy(aModelID.Left(CTelephony::KPhoneModelIdSize)); |
|
125 } |
|
126 TRACE_FUNC_EXIT |
|
127 } |
|
128 |
|
129 |
|
130 void CCGMMCommandHandler::SetTelephonyError(TInt aTelError) |
|
131 { |
|
132 TRACE_FUNC_ENTRY |
|
133 iTelError = aTelError; |
|
134 TRACE_FUNC_EXIT |
|
135 } |
|
136 |
|
137 |
|