|
1 /* |
|
2 * Copyright (c) 2002 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: Mapping Call To Bubble |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CPHONEBUBBLEMAPPING_H |
|
20 #define __CPHONEBUBBLEMAPPING_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <bmbubblemanager.h> |
|
25 |
|
26 // FORWARD DECLARATIONS |
|
27 |
|
28 // CLASS DECLARATION |
|
29 |
|
30 /** |
|
31 * It defines a single item in mapping. |
|
32 */ |
|
33 class TMappingItem |
|
34 { |
|
35 public: |
|
36 TInt iCallId; |
|
37 CBubbleManager::TBubbleId iBubbleId; |
|
38 CBubbleManager::TPhoneCallState iCallState; |
|
39 |
|
40 // NOT OWNED |
|
41 CFbsBitmap* iThumbnail; // the thumbnail to be displayed in the |
|
42 // call bubble |
|
43 }; |
|
44 |
|
45 /** |
|
46 * It keeps up mapping from call objects to bubble ids. |
|
47 */ |
|
48 class CPhoneBubbleMapping |
|
49 : public CBase |
|
50 { |
|
51 public: // Constructors and destructor |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 * |
|
56 * @param aMaximumAmount It contains maximum amount of |
|
57 * calls at the same time. |
|
58 */ |
|
59 static CPhoneBubbleMapping* NewL( |
|
60 TInt aMaximumAmount ); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 */ |
|
65 ~CPhoneBubbleMapping(); |
|
66 |
|
67 public: // New functions |
|
68 |
|
69 /** |
|
70 * Find a bubble id by call id. |
|
71 * |
|
72 * @param aCallId call Id. |
|
73 * @param aId It will contain bubble id corresponding to the call. |
|
74 * @return ETrue iff succeeded. |
|
75 */ |
|
76 TBool FindBubbleByCall( |
|
77 TInt aCallId, |
|
78 CBubbleManager::TBubbleId& aId ) const; |
|
79 |
|
80 /** |
|
81 * Find call id by bubble id. |
|
82 * |
|
83 * @param aId bubble id. |
|
84 * @param aCallId It will contain call corresponding to the bubble. |
|
85 * @return ETrue iff succeeded. |
|
86 */ |
|
87 TBool FindCallByBubble( |
|
88 CBubbleManager::TBubbleId aId, |
|
89 TInt& aCallId ) const; |
|
90 |
|
91 /** |
|
92 * Find thumbnail id by call id. |
|
93 * |
|
94 * @param aCallId call Id. |
|
95 * @return the thumbnail iff succeeded. |
|
96 */ |
|
97 const CFbsBitmap* FindThumbnailByCall( |
|
98 TInt aCallId ) const; |
|
99 |
|
100 /** |
|
101 * Add to mapping. |
|
102 * |
|
103 * Note that method panics if there already is an item with |
|
104 * the same call or allocation fails. |
|
105 * |
|
106 * @param aId It is the id of the call bubble. |
|
107 * @param aCallId It is call id corresponding to the bubble. |
|
108 * @param aThumbnail is the thumbnail attached to the bubble |
|
109 */ |
|
110 void AddToMappingL( |
|
111 CBubbleManager::TBubbleId aId, |
|
112 TInt aCallId, |
|
113 CBubbleManager::TPhoneCallState aCallState, |
|
114 CFbsBitmap* aThumbnail |
|
115 ); |
|
116 |
|
117 /** |
|
118 * Remove from mapping. |
|
119 * |
|
120 * @param aCallId The call id |
|
121 */ |
|
122 void RemoveFromMapping( |
|
123 TInt aCallId ); |
|
124 |
|
125 /** |
|
126 * Returns total amount of items in mapping. |
|
127 * |
|
128 * @return amount of items in mapping. |
|
129 */ |
|
130 TInt ItemCount() const; |
|
131 |
|
132 /** |
|
133 * Returns bubble at position. |
|
134 * |
|
135 * @param aIndex position. |
|
136 * @return id of the corresponding bubble. |
|
137 */ |
|
138 CBubbleManager::TBubbleId BubbleAt( TInt aIndex ) const; |
|
139 |
|
140 /** |
|
141 * Returns call id at position. |
|
142 * |
|
143 * @param aIndex position. |
|
144 * @return corresponding call id. |
|
145 */ |
|
146 TInt CallIdAt( TInt aIndex ) const; |
|
147 |
|
148 /** |
|
149 * Returns Thumbnail pointer at position. |
|
150 * |
|
151 * @param aIndex position. |
|
152 * @return corresponding thumbnail |
|
153 */ |
|
154 const CFbsBitmap* ThumbnailAt( TInt aIndex ) const; |
|
155 |
|
156 /** |
|
157 * update Thumbnail pointer at position. this function |
|
158 * will release the memory if the current status of the |
|
159 * thumbnail pointer is not NULL |
|
160 * |
|
161 * @param aCallId the call ID |
|
162 * @param corresponding thumbnail |
|
163 * @return none |
|
164 */ |
|
165 void SetThumbnailByCall( |
|
166 TInt aCallId, |
|
167 CFbsBitmap* aThumbnail ); |
|
168 |
|
169 /** |
|
170 * update CallState at position. |
|
171 * |
|
172 * @param aCallId the call ID |
|
173 * @param corresponding callState |
|
174 * @return none |
|
175 */ |
|
176 void SetCallState( |
|
177 TInt aCallId, |
|
178 CBubbleManager::TPhoneCallState aCallState ); |
|
179 |
|
180 /** |
|
181 * Find callState by call id. |
|
182 * |
|
183 * @param aCallId call Id. |
|
184 * @return the callState if succeeded. |
|
185 */ |
|
186 CBubbleManager::TPhoneCallState FindCallStateByCall( |
|
187 TInt aCallId ) const; |
|
188 |
|
189 /** |
|
190 * Returns CallState at position. |
|
191 * |
|
192 * @param aIndex position. |
|
193 * @return callState |
|
194 */ |
|
195 CBubbleManager::TPhoneCallState CallStateAt( TInt aIndex ) const; |
|
196 |
|
197 /** |
|
198 * update callState at position. |
|
199 * |
|
200 * @param aCallId the call ID |
|
201 * @param aCallState |
|
202 * @return none |
|
203 */ |
|
204 void SetCallStateByCall( |
|
205 TInt aCallId, |
|
206 CBubbleManager::TPhoneCallState aCallState ); |
|
207 |
|
208 /** |
|
209 * Find callId by callState. |
|
210 * |
|
211 * @param aCallState call state. |
|
212 * @return the callId if succeeded |
|
213 * and -1 if not found. |
|
214 */ |
|
215 TInt FindCallIdByCallState( |
|
216 CBubbleManager::TPhoneCallState aCallState ); |
|
217 |
|
218 private: |
|
219 /** |
|
220 * update Thumbnail pointer at position. |
|
221 * If user need to free the thumbnail, this call should |
|
222 * be used instead of user doing "delete thumbnail" |
|
223 * the user can call SetThumbnailAt( index , NULL ) to |
|
224 * release and reset the pointer |
|
225 * |
|
226 * @param aIndex position. |
|
227 * @param corresponding thumbnail |
|
228 * @return none |
|
229 */ |
|
230 void SetThumbnailAt( |
|
231 TInt aIndex, |
|
232 CFbsBitmap* aThumbnail); |
|
233 |
|
234 /** |
|
235 * update CallState at position. |
|
236 * |
|
237 * @param aIndex position. |
|
238 * @param callState |
|
239 * @return none |
|
240 */ |
|
241 void SetCallStateAt( |
|
242 TInt aIndex, |
|
243 CBubbleManager::TPhoneCallState aCallState ); |
|
244 |
|
245 /** |
|
246 * Find the index of the item by call ID |
|
247 * |
|
248 * @param aCallId call Id. |
|
249 * @param aIndex the index of the call item |
|
250 * @return ETrue iff succeeded. |
|
251 */ |
|
252 TBool FindIndexByCall( |
|
253 TInt aCallId, |
|
254 TInt& aIndex ) const; |
|
255 |
|
256 private: |
|
257 |
|
258 /** |
|
259 * C++ default constructor. |
|
260 */ |
|
261 CPhoneBubbleMapping(); |
|
262 |
|
263 /** |
|
264 * By default Symbian OS constructor is private. |
|
265 */ |
|
266 void ConstructL( TInt aMaximumAmount ); |
|
267 |
|
268 // By default, prohibit copy constructor |
|
269 CPhoneBubbleMapping( const CPhoneBubbleMapping& ); |
|
270 // Prohibit assigment operator |
|
271 CPhoneBubbleMapping& operator= ( |
|
272 const CPhoneBubbleMapping& ); |
|
273 |
|
274 private: // Data |
|
275 |
|
276 /** |
|
277 * It defines type for array of mapping items. |
|
278 */ |
|
279 typedef CArrayFixFlat<TMappingItem> CMappingArray; |
|
280 |
|
281 /** |
|
282 * It is the mapping. |
|
283 */ |
|
284 CMappingArray* iMapping; |
|
285 |
|
286 /** |
|
287 * It is the amount of reserved items in mapping. |
|
288 */ |
|
289 TInt iMappingReserve; |
|
290 }; |
|
291 |
|
292 #endif // __CPHONEBUBBLEMAPPING_H |
|
293 |
|
294 // End of File |