|
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 "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 |
|
19 |
|
20 /************************************************************************* |
|
21 * |
|
22 * Switches |
|
23 * |
|
24 ************************************************************************/ |
|
25 |
|
26 /************************************************************************* |
|
27 * |
|
28 * System Includes |
|
29 * |
|
30 ************************************************************************/ |
|
31 |
|
32 /************************************************************************* |
|
33 * |
|
34 * Local Includes |
|
35 * |
|
36 ************************************************************************/ |
|
37 #include "assert.h" |
|
38 #include "stat_console.h" |
|
39 #include "stat.h" |
|
40 |
|
41 /************************************************************************* |
|
42 * |
|
43 * Definitions |
|
44 * |
|
45 ************************************************************************/ |
|
46 #define KConnectingStatusStr _L("STAT is connecting.") |
|
47 #define KWaitingForDataStatusStr _L("STAT is waiting for data.") |
|
48 |
|
49 /************************************************************************* |
|
50 * |
|
51 * CStatConsole |
|
52 * |
|
53 ************************************************************************/ |
|
54 CStatConsole *CStatConsole::NewL( CConsoleBase *aConsole, MNotifyLogMessage *const aMsg ) |
|
55 { |
|
56 CStatConsole *self = new (ELeave) CStatConsole(); |
|
57 CleanupStack::PushL(self); |
|
58 self->ConstructL( aConsole, aMsg ); |
|
59 CleanupStack::Pop(); |
|
60 return self; |
|
61 } |
|
62 |
|
63 void CStatConsole::ConstructL( CConsoleBase *aConsole, MNotifyLogMessage *const aMsg ) |
|
64 { |
|
65 asserte( aConsole != NULL ); |
|
66 |
|
67 iConsole = aConsole; |
|
68 iUserExitRequest=0; |
|
69 iMsg = aMsg; |
|
70 } |
|
71 |
|
72 CStatConsole::~CStatConsole( void ) |
|
73 { |
|
74 } |
|
75 |
|
76 void CStatConsole::HandleStatusChange( TInt /*aSessionId*/, TCommStatus aNewStatus ) |
|
77 { |
|
78 TPtrC status[] = { |
|
79 _L( "STAT is not running." ), |
|
80 _L( "STAT is initialising." ), |
|
81 _L( "STAT is initialised." ), |
|
82 KConnectingStatusStr, |
|
83 _L( "STAT is connected." ), |
|
84 _L( "STAT is disconnecting." ), |
|
85 _L( "STAT is disconnected." ), |
|
86 _L( "STAT is releasing." ), |
|
87 _L( "STAT is sending data."), |
|
88 KWaitingForDataStatusStr, |
|
89 _L( "<error>" ) |
|
90 }; |
|
91 if(aNewStatus==0 && iUserExitRequest==1){ //only closes down if user requested to. |
|
92 CActiveScheduler::Stop(); |
|
93 } |
|
94 |
|
95 if( aNewStatus <= 9 ) { |
|
96 // iConsole->Printf( _L("%S\n"), status[aNewStatus] ); |
|
97 iConsole->Printf( status[aNewStatus] ); |
|
98 iConsole->Printf( _L("\n") ); |
|
99 } else { |
|
100 iConsole->Printf( _L("Unknown status returned.\n") ); |
|
101 } |
|
102 } |
|
103 |
|
104 void CStatConsole::HandleError( TInt aError, void * /*aErrorData*/ ) |
|
105 { |
|
106 // If aError is < 0 then it is an EPOC error code, if it is > 0 then |
|
107 // it is one of my error codes. aErrorData is defined for each code |
|
108 switch( aError ) |
|
109 { |
|
110 case KErrAccessDenied: |
|
111 iConsole->Printf( _L("Comm port access denied.\n") ); |
|
112 break; |
|
113 |
|
114 case KErrNotSupported: |
|
115 iConsole->Printf( _L("Unsupported comm port.\n") ); |
|
116 break; |
|
117 |
|
118 case KErrCancel: |
|
119 iConsole->Printf( _L("Operation cancelled.\n") ); |
|
120 break; |
|
121 |
|
122 case KErrDisconnected: |
|
123 break; |
|
124 |
|
125 default: |
|
126 iConsole->Printf( _L("Error occurred - %d.\n"), aError ); |
|
127 break; |
|
128 } |
|
129 } |
|
130 |
|
131 void CStatConsole::HandleInfo( const TDesC *aInfo ) |
|
132 { |
|
133 if( aInfo != NULL ) { |
|
134 iConsole->Printf( _L("%S\n"), aInfo ); |
|
135 } |
|
136 } |
|
137 |
|
138 void CStatConsole::UserExitRequest( ) |
|
139 { |
|
140 iUserExitRequest=1; |
|
141 } |