|
1 /* |
|
2 * Copyright (c) 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 the License "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: Groups messages and sends them to clients.* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32cmn.h> |
|
22 #include <mpxvideo_debug.h> |
|
23 #include <mpxmediacontainerdefs.h> |
|
24 #include <mpxmediageneraldefs.h> |
|
25 #include <mpxmessagegeneraldefs.h> |
|
26 #include <mpxcommandgeneraldefs.h> |
|
27 #include <mpxcollectioncommanddefs.h> |
|
28 #include <mpxmessagecontainerdefs.h> |
|
29 #include <vcxmyvideosuids.h> |
|
30 #include "vcxmyvideoscollectionplugin.h" |
|
31 #include "vcxmyvideoscollectionutil.h" |
|
32 #include "vcxmyvideosmessagelist_stub.h" |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS ============================== |
|
35 |
|
36 const TInt KMPXIdLeave = 999; |
|
37 |
|
38 // ---------------------------------------------------------------------------- |
|
39 // Two-phased constructor. |
|
40 // ---------------------------------------------------------------------------- |
|
41 // |
|
42 CVcxMyVideosMessageList* CVcxMyVideosMessageList::NewL( |
|
43 CVcxMyVideosCollectionPlugin& aCollection ) |
|
44 { |
|
45 CVcxMyVideosMessageList* self = new (ELeave) CVcxMyVideosMessageList( aCollection ); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop(self); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // Destructor. |
|
54 // ---------------------------------------------------------------------------- |
|
55 // |
|
56 CVcxMyVideosMessageList::~CVcxMyVideosMessageList() |
|
57 { |
|
58 //delete iMessageList; |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // Constructor. |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 CVcxMyVideosMessageList::CVcxMyVideosMessageList( CVcxMyVideosCollectionPlugin& aCollection ) |
|
66 : iCollection( aCollection ) |
|
67 { |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------------------------------- |
|
71 // Symbian 2nd phase constructor can leave. |
|
72 // ---------------------------------------------------------------------------- |
|
73 // |
|
74 void CVcxMyVideosMessageList::ConstructL () |
|
75 { |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------------------------------------------------------------- |
|
79 // CVcxMyVideosMessageList::AddEventL |
|
80 // ---------------------------------------------------------------------------------------------------------- |
|
81 // |
|
82 void CVcxMyVideosMessageList::AddEventL( const TMPXItemId& aId, |
|
83 TMPXChangeEventType aChange, TInt32 aExtraInfo, CMPXMedia* aVideo ) |
|
84 { |
|
85 //MPX_FUNC("CVcxMyVideosMessageList::AddEventL"); |
|
86 |
|
87 if( aId.iId1 == KMPXIdLeave ) |
|
88 User::Leave( KErrCorrupt ); |
|
89 |
|
90 CreateMessageListL(); //does nothing if already created |
|
91 |
|
92 #if _DEBUG |
|
93 //MPX_DEBUG1("CVcxMyVideosMessageList:: ----------------------------------------------." ); |
|
94 |
|
95 switch ( aChange ) |
|
96 { |
|
97 case EMPXItemDeleted: |
|
98 //MPX_DEBUG4("CVcxMyVideosMessageList:: MPXID(%d,%d), aChange = EMPXItemDeleted, aExtraInfo = %d", |
|
99 //aId.iId1, aId.iId2, aExtraInfo ); |
|
100 break; |
|
101 case EMPXItemInserted: |
|
102 //MPX_DEBUG4("CVcxMyVideosMessageList:: MPXID(%d,%d), aChange = EMPXItemInserted, aExtraInfo = %d", |
|
103 //aId.iId1, aId.iId2, aExtraInfo ); |
|
104 break; |
|
105 case EMPXItemModified: |
|
106 //MPX_DEBUG4("CVcxMyVideosMessageList:: MPXID(%d,%d), aChange = EMPXItemModified, aExtraInfo = %d", |
|
107 //aId.iId1, aId.iId2, aExtraInfo ); |
|
108 break; |
|
109 } |
|
110 |
|
111 //MPX_DEBUG1("CVcxMyVideosMessageList:: ----------------------------------------------'" ); |
|
112 #endif |
|
113 |
|
114 if ( AlreadyInMessageListL( aId, aChange, aExtraInfo ) ) |
|
115 { |
|
116 //MPX_DEBUG1("CVcxMyVideosMessageList:: already in message list, skipping add"); |
|
117 return; |
|
118 } |
|
119 |
|
120 CMPXMessage* message = CMPXMedia::NewL(); |
|
121 CleanupStack::PushL( message ); // 1-> |
|
122 |
|
123 message->SetTObjectValueL<TMPXMessageId>(KMPXMessageGeneralId, KMPXMessageIdItemChanged); |
|
124 message->SetTObjectValueL<TUid>(KMPXMessageCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection)); |
|
125 message->SetTObjectValueL<TMPXChangeEventType>(KMPXMessageChangeEventType, aChange); |
|
126 message->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, aId); |
|
127 message->SetTObjectValueL<TMPXGeneralCategory>( KMPXMessageMediaGeneralCategory, EMPXCollection ); |
|
128 |
|
129 if ( aVideo && aChange == EMPXItemInserted ) |
|
130 { |
|
131 message->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, aVideo ); |
|
132 } |
|
133 |
|
134 if ( aExtraInfo ) |
|
135 { |
|
136 message->SetTObjectValueL<TInt32>( KVcxMediaMyVideosInt32Value, aExtraInfo ); |
|
137 } |
|
138 |
|
139 //MPX_DEBUG1("CVcxMyVideosMessageList:: appending to message array"); |
|
140 |
|
141 iMessageArray->AppendL( message ); // ownership moves |
|
142 |
|
143 CleanupStack::Pop( message ); // <-1 |
|
144 |
|
145 iMessageCount++; |
|
146 iMessageList->SetTObjectValueL<TInt>( KMPXMessageArrayCount, iMessageCount ); |
|
147 } |
|
148 |
|
149 // ---------------------------------------------------------------------------------------------------------- |
|
150 // CVcxMyVideosMessageList::AddEventL |
|
151 // ---------------------------------------------------------------------------------------------------------- |
|
152 // |
|
153 void CVcxMyVideosMessageList::AddEventL( TInt aEvent ) |
|
154 { |
|
155 TMPXItemId itemId; |
|
156 itemId.iId1 = KVcxCommandIdMyVideos; |
|
157 CMPXMedia* msg = CMPXMedia::NewL(); |
|
158 CleanupStack::PushL( msg ); // 1-> |
|
159 msg->SetTObjectValueL<TMPXMessageId>( KMPXMessageGeneralId, itemId ); |
|
160 msg->SetTObjectValueL<TUid>(KMPXMessageCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection)); |
|
161 |
|
162 msg->SetTObjectValueL<TInt>( KVcxMediaMyVideosCommandId, aEvent ); |
|
163 AddL( msg ); |
|
164 CleanupStack::Pop( msg ); // <-1 |
|
165 } |
|
166 |
|
167 // ---------------------------------------------------------------------------------------------------------- |
|
168 // CVcxMyVideosMessageList::AlreadyInMessageListL |
|
169 // ---------------------------------------------------------------------------------------------------------- |
|
170 // |
|
171 TBool CVcxMyVideosMessageList::AlreadyInMessageListL( const TMPXItemId& aId, |
|
172 TMPXChangeEventType aChange, TInt32 aExtraInfo ) |
|
173 { |
|
174 TMPXItemId itemId; |
|
175 TMPXChangeEventType event; |
|
176 TInt32 extraInfo; |
|
177 CMPXMedia* media; |
|
178 TInt count = iMessageArray->Count(); |
|
179 |
|
180 for ( TInt i = 0; i < count; i++ ) |
|
181 { |
|
182 media = iMessageArray->AtL( i ); |
|
183 |
|
184 if ( media->IsSupported( KMPXMessageMediaGeneralId ) && |
|
185 media->IsSupported( KMPXMessageChangeEventType ) ) |
|
186 { |
|
187 itemId = media->ValueTObjectL<TMPXItemId>( KMPXMessageMediaGeneralId ); |
|
188 event = media->ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ); |
|
189 |
|
190 if ( aId == itemId && aChange == event ) |
|
191 { |
|
192 extraInfo = 0; |
|
193 if ( media->IsSupported( KVcxMediaMyVideosInt32Value ) ) |
|
194 { |
|
195 extraInfo = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value ); |
|
196 } |
|
197 if ( aExtraInfo == extraInfo ) |
|
198 { |
|
199 return ETrue; |
|
200 } |
|
201 else |
|
202 { |
|
203 return EFalse; |
|
204 } |
|
205 } |
|
206 } |
|
207 } |
|
208 return EFalse; |
|
209 } |
|
210 |
|
211 // ---------------------------------------------------------------------------------------------------------- |
|
212 // CVcxMyVideosMessageList::AddL |
|
213 // ---------------------------------------------------------------------------------------------------------- |
|
214 // |
|
215 void CVcxMyVideosMessageList::AddL( CMPXMessage* aMessage ) |
|
216 { |
|
217 if ( !aMessage ) |
|
218 { |
|
219 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL aMessage is NULL!!"); |
|
220 return; |
|
221 } |
|
222 |
|
223 #ifdef _DEBUG |
|
224 if ( aMessage->IsSupported( KVcxMediaMyVideosCommandId ) ) |
|
225 { |
|
226 switch ( aMessage->ValueTObjectL<TUint32>( KVcxMediaMyVideosCommandId ) ) |
|
227 { |
|
228 case KVcxMessageMyVideosItemsAppended: |
|
229 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL adding msg KVcxMessageMyVideosItemsAppended"); |
|
230 break; |
|
231 |
|
232 case KVcxMessageMyVideosListComplete: |
|
233 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL adding msg KVcxMessageMyVideosListComplete"); |
|
234 break; |
|
235 |
|
236 case KVcxMessageMyVideosMoveOrCopyStarted: |
|
237 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL adding msg KVcxMessageMyVideosMoveOrCopyStarted"); |
|
238 break; |
|
239 |
|
240 case KVcxMessageMyVideosDeleteStarted: |
|
241 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL adding msg KVcxMessageMyVideosDeleteStarted"); |
|
242 break; |
|
243 |
|
244 case KVcxMessageMyVideosMoveResp: |
|
245 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL adding msg KVcxMessageMyVideosMoveResp"); |
|
246 break; |
|
247 |
|
248 case KVcxMessageMyVideosGetMediasByMpxIdResp: |
|
249 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL adding msg KVcxMessageMyVideosGetMediasByMpxIdResp"); |
|
250 break; |
|
251 |
|
252 case KVcxMessageMyVideosCopyResp: |
|
253 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL adding msg KVcxMessageMyVideosCopyResp"); |
|
254 break; |
|
255 |
|
256 case KVcxMessageMyVideosDeleteResp: |
|
257 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL adding msg KVcxMessageMyVideosDeleteResp"); |
|
258 break; |
|
259 default: |
|
260 //MPX_DEBUG1("CVcxMyVideosMessageList::AddL unknown message"); |
|
261 break; |
|
262 } |
|
263 } |
|
264 #endif |
|
265 |
|
266 CreateMessageListL(); //does nothing if already created |
|
267 iMessageArray->AppendL( aMessage ); // ownership moves |
|
268 iMessageCount++; |
|
269 iMessageList->SetTObjectValueL<TInt>( KMPXMessageArrayCount, iMessageCount ); |
|
270 } |
|
271 |
|
272 // ---------------------------------------------------------------------------------------------------------- |
|
273 // CVcxMyVideosMessageList::SendL |
|
274 // ---------------------------------------------------------------------------------------------------------- |
|
275 // |
|
276 void CVcxMyVideosMessageList::SendL() |
|
277 { |
|
278 //MPX_FUNC("CVcxMyVideosMessageList::SendL()"); |
|
279 if ( iMessageCount == 0 || !iMessageList ) |
|
280 { |
|
281 //MPX_DEBUG1("CVcxMyVideosMessageList:: iMessageList is empty or NULL, skipping send"); |
|
282 return; |
|
283 } |
|
284 |
|
285 iCollection.SendMessages( *iMessageList ); |
|
286 delete iMessageList; |
|
287 iMessageList = NULL; |
|
288 iMessageArray = NULL; |
|
289 iMessageCount = 0; |
|
290 } |
|
291 |
|
292 // ---------------------------------------------------------------------------- |
|
293 // CVcxMyVideosMessageList::CreateMessageListL |
|
294 // ---------------------------------------------------------------------------- |
|
295 // |
|
296 void CVcxMyVideosMessageList::CreateMessageListL() |
|
297 { |
|
298 if ( !iMessageList ) |
|
299 { |
|
300 iMessageList = TVcxMyVideosCollectionUtil::CreateEmptyMessageListL(); |
|
301 iMessageArray = iMessageList->Value<CMPXMessageArray>( KMPXMessageArrayContents ); |
|
302 |
|
303 iMessageList->SetTObjectValueL<TMPXMessageId>(KMPXMessageGeneralId, KVcxCommandIdMyVideos); |
|
304 iMessageList->SetTObjectValueL<TInt>(KVcxMediaMyVideosCommandId, KVcxMessageMyVideosMessageArray ); |
|
305 iMessageList->SetTObjectValueL<TUid>(KMPXMessageCollectionId, TUid::Uid(KVcxUidMyVideosMpxCollection)); |
|
306 //iMessageList->SetTObjectValueL<TMPXChangeEventType>(KMPXMessageChangeEventType, aChange); |
|
307 //iMessageList->SetTObjectValueL<TMPXItemId>(KMPXMessageMediaGeneralId, TMPXItemId(0, 0) ); |
|
308 iMessageCount = 0; |
|
309 } |
|
310 } |
|
311 // End of file |
|
312 |