19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include "PhoneHandlerCallState.h" |
20 #include "PhoneHandlerCallState.h" |
21 #include "PhoneHandlerControl.h" |
21 #include "PhoneHandlerControl.h" |
22 #include "PhoneHandlerDebug.h" |
22 #include "PhoneHandlerDebug.h" |
23 #include <ctsydomainpskeys.h> |
23 #include <ctsydomainpskeys.h> |
|
24 |
|
25 #include <ccallinformation.h> |
|
26 #include <mcall.h> |
|
27 #include <ccallinfoiter.h> |
|
28 |
24 |
29 |
25 // EXTERNAL DATA STRUCTURES |
30 // EXTERNAL DATA STRUCTURES |
26 |
31 |
27 // EXTERNAL FUNCTION PROTOTYPES |
32 // EXTERNAL FUNCTION PROTOTYPES |
28 |
33 |
48 // C++ default constructor can NOT contain any code, that |
53 // C++ default constructor can NOT contain any code, that |
49 // might leave. |
54 // might leave. |
50 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
51 // |
56 // |
52 CPhoneHandlerCallState::CPhoneHandlerCallState( CPhoneHandlerControl& aControl ) |
57 CPhoneHandlerCallState::CPhoneHandlerCallState( CPhoneHandlerControl& aControl ) |
53 : CActive(CActive::EPriorityStandard), |
58 : iControl( aControl ) |
54 iControl( aControl ) |
|
55 { |
59 { |
56 CActiveScheduler::Add(this); |
|
57 } |
60 } |
58 |
61 |
59 // ----------------------------------------------------------------------------- |
62 // ----------------------------------------------------------------------------- |
60 // CPhoneHandlerCallState::ConstructL |
63 // CPhoneHandlerCallState::ConstructL |
61 // Symbian 2nd phase constructor can leave. |
64 // Symbian 2nd phase constructor can leave. |
63 // |
66 // |
64 void CPhoneHandlerCallState::ConstructL() |
67 void CPhoneHandlerCallState::ConstructL() |
65 { |
68 { |
66 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::ConstructL() start" ); |
69 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::ConstructL() start" ); |
67 |
70 |
68 // Allows CPhoneHandlerCallState to start to listen S60 call states. |
71 // Allows CPhoneHandlerCallState to start to listen call states. |
69 User::LeaveIfError( |
72 iInfo = CCallInformation::NewL(); |
70 iProperty.Attach( KPSUidCtsyCallInformation, KCTsyCallState ) ); |
73 iInfo->NotifyCallInformationChanges(*this); |
71 |
|
72 Subscribe(); |
|
73 |
74 |
74 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::ConstructL() end" ); |
75 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::ConstructL() end" ); |
75 } |
76 } |
76 |
77 |
77 // ----------------------------------------------------------------------------- |
78 // ----------------------------------------------------------------------------- |
92 |
93 |
93 // Destructor |
94 // Destructor |
94 CPhoneHandlerCallState::~CPhoneHandlerCallState() |
95 CPhoneHandlerCallState::~CPhoneHandlerCallState() |
95 { |
96 { |
96 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::~CPhoneHandlerCallState() start" ); |
97 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::~CPhoneHandlerCallState() start" ); |
97 |
98 |
98 Cancel(); |
99 if ( iInfo ) |
99 iProperty.Cancel(); |
100 { |
100 iProperty.Close(); |
101 iInfo->CancelNotification(); |
101 |
102 delete iInfo; |
|
103 } |
|
104 |
102 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::~CPhoneHandlerCallState() end" ); |
105 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::~CPhoneHandlerCallState() end" ); |
103 } |
106 } |
104 |
107 |
105 // ----------------------------------------------------------------------------- |
108 // ----------------------------------------------------------------------------- |
106 // CPhoneHandlerCallState::RunL() |
109 // CPhoneHandlerCallState::CallInformationChanged |
107 // Informs caller of an asynchronous request that it has been completed. |
|
108 // (other items were commented in a header). |
|
109 // ----------------------------------------------------------------------------- |
110 // ----------------------------------------------------------------------------- |
110 // |
111 // |
111 void CPhoneHandlerCallState::RunL() |
112 void CPhoneHandlerCallState::CallInformationChanged() |
112 { |
113 { |
113 COM_TRACE_1( "[PHONECMDHANDLER] CPhoneHandlerCallState::RunL() - return code = %d", iStatus.Int() ); |
114 TRAP_IGNORE( CallInformationChangedL() ); |
114 |
|
115 TInt state( 0 ); |
|
116 iProperty.Get( state ); |
|
117 |
|
118 COM_TRACE_1( "[PHONECMDHANDLER] CPhoneHandlerCallState - KTelephonyCallState = %d", state ); |
|
119 |
|
120 if( iStatus.Int() == KErrNone ) |
|
121 { |
|
122 iControl.NotifyCallState( state ); |
|
123 } |
|
124 |
|
125 Subscribe(); |
|
126 } |
115 } |
127 |
116 |
128 // ----------------------------------------------------------------------------- |
117 // ----------------------------------------------------------------------------- |
129 // CPhoneHandlerCallState::DoCancel |
118 // CPhoneHandlerCallState::CallInformationChangedL |
130 // (other items were commented in a header). |
|
131 // ----------------------------------------------------------------------------- |
119 // ----------------------------------------------------------------------------- |
132 // |
120 // |
133 void CPhoneHandlerCallState::DoCancel() |
121 void CPhoneHandlerCallState::CallInformationChangedL() |
134 { |
122 { |
135 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::DoCancel()" ); |
123 CCallInfoIter& iter = iInfo->GetCallsL(); |
136 |
124 for( iter.First(); !iter.IsDone(); iter.Next() ) |
137 iProperty.Cancel(); |
125 { |
138 } |
126 const MCall* call ( &iter.Current() ); |
|
127 if ( call ) |
|
128 { |
|
129 iControl.NotifyCallStateL( call ); |
|
130 } |
|
131 } |
|
132 } |
139 |
133 |
140 // ----------------------------------------------------------------------------- |
|
141 // CPhoneHandlerCallState::Subscribe |
|
142 // Start to listen changes in call state. |
|
143 // (other items were commented in a header). |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void CPhoneHandlerCallState::Subscribe() |
|
147 { |
|
148 COM_TRACE_( "[PHONECMDHANDLER] CPhoneHandlerCallState::Subscribe()" ); |
|
149 |
|
150 iProperty.Subscribe( iStatus ); |
|
151 SetActive(); |
|
152 } |
|
153 |
|
154 // |
|
155 // End of file |
134 // End of file |