|
1 /* |
|
2 * Copyright (c) 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 #include <callremotepartyinformation.h> |
|
19 #include <mcallremotepartyinfoobserver.h> |
|
20 |
|
21 #include "ccallremotepartyinformationimpl.h" |
|
22 #include "ccallremotepartyinfoiter.h" |
|
23 #include "telsrvlogger.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // C++ constructor |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CCallRemotePartyInformationImpl::CCallRemotePartyInformationImpl() |
|
32 : CTelSrvBase( ) |
|
33 { |
|
34 } |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Symbian second-phase constructor. |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 void CCallRemotePartyInformationImpl:: |
|
41 ConstructL(CMediatorService* aMediatorService) |
|
42 { |
|
43 TSLOGSTRING("CCallInformationImpl::ConstructL >"); |
|
44 CTelSrvBase::BaseConstructL( aMediatorService ); |
|
45 |
|
46 TSLOGSTRING("CCallInformationImpl::ConstructL <"); |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Static constructor |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CCallRemotePartyInformationImpl* CCallRemotePartyInformationImpl::NewL() |
|
55 { |
|
56 CCallRemotePartyInformationImpl* self = |
|
57 CCallRemotePartyInformationImpl::NewLC(); |
|
58 |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // Static constructor |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CCallRemotePartyInformationImpl* CCallRemotePartyInformationImpl::NewLC() |
|
69 { |
|
70 CCallRemotePartyInformationImpl* self = |
|
71 new( ELeave ) CCallRemotePartyInformationImpl; |
|
72 CleanupStack::PushL( self ); |
|
73 |
|
74 CMediatorService* mediatorService = |
|
75 CMediatorService::NewLC( CMediatorService::ECallRemotePartyInfo ); |
|
76 |
|
77 self->ConstructL(mediatorService); |
|
78 CleanupStack::Pop( mediatorService ); |
|
79 return self; |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // Destructor |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 CCallRemotePartyInformationImpl::~CCallRemotePartyInformationImpl() |
|
88 { |
|
89 delete iRemotePartyInfos; |
|
90 delete iRemotePartyInfoIter; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // Saves the observer call information changes. |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CCallRemotePartyInformationImpl::NotifyChanges( |
|
98 MCallRemotePartyInformationObserver& aObserver ) |
|
99 { |
|
100 TSLOGSTRING("CCallInformationImpl::NotifyChanges <<"); |
|
101 iObserver = &aObserver; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // Removes the observer. |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CCallRemotePartyInformationImpl::CancelNotification( ) |
|
109 { |
|
110 TSLOGSTRING("CCallRemotePartyInformationImpl::CancelNotification <<"); |
|
111 iObserver = NULL; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 CCallRemotePartyInfoIter& |
|
119 CCallRemotePartyInformationImpl::GetRemotePartyInformationL( ) |
|
120 { |
|
121 TSLOGSTRING("CCallRemotePartyInformationImpl::GetRemotePartyInfoL <<"); |
|
122 if( !iRemotePartyInfoIter ) |
|
123 { |
|
124 TSLOGSTRING("GetRemotePartyInformationL; Leaves with KErrNoMemory"); |
|
125 //memory allocation failed in CommandResponseL or MediatorEventL |
|
126 User::Leave( KErrNoMemory ); |
|
127 } |
|
128 |
|
129 TSLOGSTRING("CCallRemotePartyInformationImpl::GetRemotePartyInfoL >>"); |
|
130 return *iRemotePartyInfoIter; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 const MCallRemotePartyInfo* |
|
138 CCallRemotePartyInformationImpl::GetRemotePartyInformationL( TInt aCallIndex ) |
|
139 { |
|
140 TSLOGSTRING("CCallRemotePartyInformationImpl::GetRemotePartyInfoL(aCallIndex) <<"); |
|
141 if( !iRemotePartyInfoIter ) |
|
142 { |
|
143 TSLOGSTRING("GetRemotePartyInformationL; Leaves with KErrNoMemory"); |
|
144 //memory allocation failed in CommandResponseL or MediatorEventL |
|
145 User::Leave( KErrNoMemory ); |
|
146 } |
|
147 |
|
148 for( iRemotePartyInfoIter->First(); !iRemotePartyInfoIter->IsDone(); iRemotePartyInfoIter->Next() ) |
|
149 { |
|
150 const MCallRemotePartyInfo& info( iRemotePartyInfoIter->Current() ); |
|
151 if ( info.CallIndex() == aCallIndex ) |
|
152 { |
|
153 return &info; |
|
154 } |
|
155 } |
|
156 |
|
157 return NULL; |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // From class CTelSrvBase. |
|
162 // A response to a Mediator Service command. |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 void CCallRemotePartyInformationImpl:: |
|
166 DoHandleCommandResponseL( const TDesC8& aData ) |
|
167 { |
|
168 TSLOGSTRING("CCallRemotePartyInformationImpl::DoHandleCommandResponseL <<"); |
|
169 |
|
170 iRemotePartyInfos = CCallRemotePartyInfos::NewL(); |
|
171 iRemotePartyInfos->InternalizeL( aData ); |
|
172 |
|
173 iRemotePartyInfoIter = CCallRemotePartyInfoIter::NewL( *iRemotePartyInfos ); |
|
174 |
|
175 TSLOGSTRING("CCallRemotePartyInformationImpl::DoHandleCommandResponseL >>"); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // From class MMediatorServiceObserver |
|
180 // A Mediator Service event. |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 void CCallRemotePartyInformationImpl::DoHandleMediatorEventL( const TDesC8& aData ) |
|
184 { |
|
185 TSLOGSTRING("CCallRemotePartyInformationImpl::DoHandleMediatorEventL <<"); |
|
186 |
|
187 delete iRemotePartyInfos; |
|
188 iRemotePartyInfos = NULL; |
|
189 |
|
190 delete iRemotePartyInfoIter; |
|
191 iRemotePartyInfoIter = NULL; |
|
192 |
|
193 iRemotePartyInfos = CCallRemotePartyInfos::NewL(); |
|
194 iRemotePartyInfos->InternalizeL( aData ); |
|
195 |
|
196 iRemotePartyInfoIter = CCallRemotePartyInfoIter::NewL( *iRemotePartyInfos ); |
|
197 |
|
198 if( iObserver ) |
|
199 { |
|
200 iObserver->CallRemotePartyInformationChanged(); |
|
201 } |
|
202 |
|
203 TSLOGSTRING("CCallRemotePartyInformationImpl::DoHandleMediatorEventL >>"); |
|
204 } |