|
1 /* |
|
2 * Copyright (c) 2007 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: Implements the class CSPEtelLineStatusMonitor |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <etelmm.h> |
|
21 |
|
22 #include "cspetellinestatusmonitor.h" |
|
23 #include "mcsplinestatusobserver.h" |
|
24 #include "csplogger.h" |
|
25 #include "cspconsts.h" |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CSPEtelCallAddedMonitor::NewL. |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CSPEtelLineStatusMonitor* CSPEtelLineStatusMonitor::NewL( |
|
33 MCSPLineStatusObserver& aObserver, |
|
34 RMobileLine& aLine, |
|
35 RCSPLineContainer::TCSPLineId aLineId ) |
|
36 { |
|
37 CSPLOGSTRING(CSPOBJECT, |
|
38 "CSPEtelLineStatusMonitor::NewL()" ); |
|
39 CSPEtelLineStatusMonitor* self = new ( ELeave ) CSPEtelLineStatusMonitor( |
|
40 aObserver, aLine, aLineId ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Destructs the object by canceling first ongoing monitoring. |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CSPEtelLineStatusMonitor::~CSPEtelLineStatusMonitor( ) |
|
49 { |
|
50 CSPLOGSTRING(CSPOBJECT, |
|
51 "CSPEtelLineStatusMonitor::~CSPEtelLineStatusMonitor()" ); |
|
52 Cancel(); |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // Starts the monitor. |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 void CSPEtelLineStatusMonitor::StartMonitoring() |
|
60 { |
|
61 CSPLOGSTRING(CSPINT, "CSPEtelLineStatusMonitor::StartMonitoring()" ); |
|
62 |
|
63 if ( !IsActive() ) |
|
64 { |
|
65 CSPLOGSTRING( CSPINT, |
|
66 "CSP: CSPEtelLineStatusMonitor::StartMonitoring: Request \ |
|
67 iLine.NotifyStatusChange( iStatus, iLineStatus )" ); |
|
68 |
|
69 iLine.NotifyMobileLineStatusChange( iStatus, iLineStatus ); |
|
70 SetActive(); |
|
71 } |
|
72 else |
|
73 { |
|
74 CSPLOGSTRING( CSPERROR, |
|
75 "CSP: CSPEtelLineStatusMonitor::StartMonitoring: Already active" ); |
|
76 } |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // From CActive. |
|
81 // Handles line status change notifying. |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CSPEtelLineStatusMonitor::RunL() |
|
85 { |
|
86 CSPLOGSTRING2( CSPINT, "CSPEtelLineStatusMonitor::RunL: %d", iStatus.Int() ); |
|
87 |
|
88 if ( iStatus == KErrNone ) |
|
89 { |
|
90 CSPLOGSTRING( CSPINT, "CSPEtelLineStatusMonitor::RunL status changed") |
|
91 iObserver.LineStatusChanged( iLine, iLineId, iLineStatus ); |
|
92 |
|
93 StartMonitoring(); |
|
94 } |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // From CActive |
|
99 // Canceling functionality. |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 void CSPEtelLineStatusMonitor::DoCancel() |
|
103 { |
|
104 CSPLOGSTRING( CSPINT, "CSPEtelLineStatusMonitor::DoCancel" ); |
|
105 |
|
106 if ( iStatus == KRequestPending ) |
|
107 { |
|
108 CSPLOGSTRING( CSPINT, |
|
109 "CSPEtelLineStatusMonitor::DoCancel Canceling pending request" ); |
|
110 iLine.CancelAsyncRequest( EMobileLineNotifyMobileLineStatusChange ); |
|
111 } |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // Constructs the monitor. |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 CSPEtelLineStatusMonitor::CSPEtelLineStatusMonitor( |
|
119 MCSPLineStatusObserver& aObserver, |
|
120 RMobileLine& aLine, |
|
121 RCSPLineContainer::TCSPLineId aLineId ) : |
|
122 CActive( EPriorityStandard ), |
|
123 iLine( aLine ), |
|
124 iLineId( aLineId ), |
|
125 iObserver( aObserver ) |
|
126 { |
|
127 CSPLOGSTRING(CSPOBJECT, |
|
128 "CSPEtelLineStatusMonitor::CSPEtelLineStatusMonitor()" ); |
|
129 CActiveScheduler::Add( this ); |
|
130 } |
|
131 |
|
132 |
|
133 // End of file |