|
1 /* |
|
2 * Copyright (c) 2008-2008 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: Forwards call state changes to Mediator |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cccecallinfomediator.h" |
|
20 |
|
21 #include <MediatorDomainUIDs.h> |
|
22 #include <callinformation.h> |
|
23 #include <MediatorCommandResponder.h> |
|
24 #include <MediatorEventProvider.h> |
|
25 |
|
26 #include "cccecallinfomediatorupdater.h" |
|
27 #include "cccecallinfoconverter.h" |
|
28 #include "cccelogger.h" |
|
29 |
|
30 // ======== MEMBER FUNCTIONS ======== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // Static constructor |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CCCECallInfoMediator* CCCECallInfoMediator::NewL( |
|
37 MCCECallArray& aCallArray ) |
|
38 { |
|
39 CCCECallInfoMediator* self = CCCECallInfoMediator::NewLC( aCallArray ); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Static constructor |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CCCECallInfoMediator* CCCECallInfoMediator::NewLC( |
|
50 MCCECallArray& aCallArray ) |
|
51 { |
|
52 CCCECallInfoMediator* self = new( ELeave ) CCCECallInfoMediator; |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL( aCallArray ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // Destructor |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CCCECallInfoMediator::~CCCECallInfoMediator() |
|
64 { |
|
65 if ( iEventProvider ) |
|
66 { |
|
67 TInt ignore = iEventProvider->UnregisterEvent( KMediatorTelephonyDomain, |
|
68 KCatCallInformation, EChangesInCallStates ); |
|
69 } |
|
70 delete iEventProvider; |
|
71 if ( iResponder ) |
|
72 { |
|
73 TInt ignore = iResponder->UnregisterCommand( KMediatorTelephonyDomain, |
|
74 KCatCallInformation, EGetAllCallStates ); |
|
75 } |
|
76 delete iResponder; |
|
77 delete iUpdater; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // Updates call infos |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 void CCCECallInfoMediator::UpdateCallInfos() |
|
85 { |
|
86 CCELOGSTRING( "CCCECallInfoMediator::UpdateCallInfos(): IN" ); |
|
87 TInt err; |
|
88 TRAP( err, iUpdater->UpdateL() ); |
|
89 CCELOGSTRING2( "CCCECallInfoMediator::UpdateCallInfos err = %d", err ); |
|
90 CCELOGSTRING( "CCCECallInfoMediator::UpdateCallInfos(): OUT" ); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // From base class MCCECallInfoMediator |
|
95 // Sends the response to mediator |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CCCECallInfoMediator::SendResponse( TInt aCommandId, const TDesC8& aData ) |
|
99 { |
|
100 CCELOGSTRING( "CCCECallInfoMediator::SendResponse(): IN" ); |
|
101 const TInt ignore( iResponder->IssueResponse( |
|
102 KMediatorTelephonyDomain, KCatCallInformation, |
|
103 aCommandId, KErrNone, aData ) ); |
|
104 CCELOGSTRING2( "CCCECallInfoMediator::SendResponse() err = %d", ignore ); |
|
105 CCELOGSTRING( "CCCECallInfoMediator::SendResponse(): OUT" ); |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // From base class MCCECallInfoMediator |
|
110 // Raises the mediator event. |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CCCECallInfoMediator::RaiseEvent( TInt aEventId, const TDesC8& aData ) |
|
114 { |
|
115 CCELOGSTRING( "CCCECallInfoMediator::RaiseEvent(): IN" ); |
|
116 TVersion version( |
|
117 KCallInformationVersionMajor, KCallInformationVersionMinor, |
|
118 KCallInformationVersionBuild ); |
|
119 const TInt ignore( iEventProvider->RaiseEvent( |
|
120 KMediatorTelephonyDomain, KCatCallInformation, |
|
121 aEventId, version, aData ) ); |
|
122 CCELOGSTRING2( "CCCECallInfoMediator::RaiseEvent() err = %d", ignore ); |
|
123 CCELOGSTRING( "CCCECallInfoMediator::RaiseEvent(): OUT" ); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // Constructor |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 CCCECallInfoMediator::CCCECallInfoMediator() |
|
131 { |
|
132 } |
|
133 |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Second phase constructor. |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CCCECallInfoMediator::ConstructL( |
|
140 MCCECallArray& aCallArray ) |
|
141 { |
|
142 // updater takes the converter ownership |
|
143 CCCECallInfoConverter* converter = new( ELeave )CCCECallInfoConverter(); |
|
144 CleanupStack::PushL( converter ); |
|
145 iUpdater = CCCECallInfoMediatorUpdater::NewL( |
|
146 *this, aCallArray, converter ); |
|
147 CleanupStack::Pop( converter ); |
|
148 |
|
149 iResponder = CMediatorCommandResponder::NewL( iUpdater ); |
|
150 TCapabilitySet caps = TCapabilitySet(); |
|
151 caps.SetEmpty(); |
|
152 TVersion version( KCallInformationVersionMajor, KCallInformationVersionMinor, |
|
153 KCallInformationVersionBuild ); |
|
154 User::LeaveIfError( iResponder->RegisterCommand( |
|
155 KMediatorTelephonyDomain, |
|
156 KCatCallInformation, |
|
157 EGetAllCallStates, |
|
158 version, |
|
159 caps, |
|
160 KMediatorTimeoutInfinite ) ); |
|
161 |
|
162 iEventProvider = CMediatorEventProvider::NewL(); |
|
163 User::LeaveIfError( |
|
164 iEventProvider->RegisterEvent( |
|
165 KMediatorTelephonyDomain, KCatCallInformation, |
|
166 EChangesInCallStates, version, caps ) ); |
|
167 |
|
168 } |
|
169 |