34
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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: Queues commands to MDS.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <mpxlog.h>
|
|
22 |
#include "vcxmyvideosmdscmdqueue.h"
|
|
23 |
#include "vcxmyvideosmdsdb.h"
|
|
24 |
#include "vcxmyvideosmdsalbums.h"
|
|
25 |
|
|
26 |
|
|
27 |
// ============================ MEMBER FUNCTIONS =============================
|
|
28 |
|
|
29 |
// ---------------------------------------------------------------------------
|
|
30 |
// Constructor
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
//
|
|
33 |
CVcxMyVideosMdsCmdQueue::CVcxMyVideosMdsCmdQueue( CVcxMyVideosMdsDb& aMdsDb )
|
|
34 |
: iMdsDb( aMdsDb )
|
|
35 |
{
|
|
36 |
}
|
|
37 |
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
// 2nd-phase constructor
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
void CVcxMyVideosMdsCmdQueue::ConstructL()
|
|
43 |
{
|
|
44 |
iQueue.Reset();
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
// Two-Phase Constructor
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CVcxMyVideosMdsCmdQueue* CVcxMyVideosMdsCmdQueue::NewL( CVcxMyVideosMdsDb& aMdsDb )
|
|
52 |
{
|
|
53 |
CVcxMyVideosMdsCmdQueue* self = new(ELeave) CVcxMyVideosMdsCmdQueue( aMdsDb );
|
|
54 |
CleanupStack::PushL( self );
|
|
55 |
self->ConstructL();
|
|
56 |
CleanupStack::Pop( self );
|
|
57 |
return self;
|
|
58 |
}
|
|
59 |
|
|
60 |
// ---------------------------------------------------------------------------
|
|
61 |
// Destructor
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
CVcxMyVideosMdsCmdQueue::~CVcxMyVideosMdsCmdQueue()
|
|
65 |
{
|
|
66 |
for ( TInt i = 0; i < iQueue.Count(); i++ )
|
|
67 |
{
|
|
68 |
delete iQueue[i];
|
|
69 |
}
|
|
70 |
iQueue.Close();
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
// CVcxMyVideosMdsCmdQueue::Cancel
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
void CVcxMyVideosMdsCmdQueue::Cancel( CVcxMyVideosMdsDb::TRequestType aType )
|
|
78 |
{
|
|
79 |
TInt count = iQueue.Count()-1;
|
|
80 |
for ( TInt i = count; i >= 0; i-- )
|
|
81 |
{
|
|
82 |
if ( iQueue[i]->iCmdType == aType || aType == CVcxMyVideosMdsDb::EAll )
|
|
83 |
{
|
|
84 |
delete iQueue[i];
|
|
85 |
iQueue[i] = NULL;
|
|
86 |
iQueue.Remove( i );
|
|
87 |
}
|
|
88 |
}
|
|
89 |
iQueue.Compress();
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
// CVcxMyVideosMdsCmdQueue::ExecuteCmdL
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
void CVcxMyVideosMdsCmdQueue::ExecuteCmdL( CVcxMyVideosMdsCmd* aCmd )
|
|
97 |
{
|
|
98 |
if ( iQueue.Count() == 0 && !iCmdInProgress )
|
|
99 |
{
|
|
100 |
DoExecuteCmdL( aCmd ); //ownership does not move
|
|
101 |
delete aCmd;
|
|
102 |
}
|
|
103 |
else
|
|
104 |
{
|
|
105 |
iQueue.AppendL( aCmd );
|
|
106 |
}
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
// CVcxMyVideosMdsCmdQueue::CmdFinished
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CVcxMyVideosMdsCmdQueue::CmdFinished()
|
|
114 |
{
|
|
115 |
iCmdInProgress = EFalse;
|
|
116 |
|
|
117 |
TInt err( KErrGeneral );
|
|
118 |
while ( err != KErrNone )
|
|
119 |
{
|
|
120 |
if ( iQueue.Count() == 0 )
|
|
121 |
{
|
|
122 |
break;
|
|
123 |
}
|
|
124 |
|
|
125 |
TInt cmdIndexToExecute;
|
|
126 |
// Let other commads bypass EGetVideoList
|
|
127 |
if ( iQueue.Count() > 1 && iQueue[0]->iCmdType == CVcxMyVideosMdsDb::EGetVideoList )
|
|
128 |
{
|
|
129 |
cmdIndexToExecute = 1;
|
|
130 |
}
|
|
131 |
else
|
|
132 |
{
|
|
133 |
cmdIndexToExecute = 0;
|
|
134 |
}
|
|
135 |
TRAP( err, DoExecuteCmdL( iQueue[cmdIndexToExecute] ) ); //ownership does not move
|
|
136 |
delete iQueue[cmdIndexToExecute];
|
|
137 |
iQueue[cmdIndexToExecute] = NULL;
|
|
138 |
iQueue.Remove( cmdIndexToExecute );
|
|
139 |
iQueue.Compress();
|
|
140 |
|
|
141 |
#ifdef _DEBUG
|
|
142 |
if ( err != KErrNone )
|
|
143 |
{
|
|
144 |
MPX_DEBUG2("CVcxMyVideosMdsCmdQueue:: MDS cmd failed: %d", err);
|
|
145 |
}
|
|
146 |
#endif
|
|
147 |
}
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// CVcxMyVideosMdsCmdQueue::DoExecuteCmdL
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
void CVcxMyVideosMdsCmdQueue::DoExecuteCmdL( CVcxMyVideosMdsCmd* aCmd )
|
|
155 |
{
|
|
156 |
switch ( aCmd->iCmdType )
|
|
157 |
{
|
|
158 |
case CVcxMyVideosMdsDb::EGetVideoList:
|
|
159 |
{
|
|
160 |
CVcxMyVideosMdsCmdGetVideoList* cmd =
|
|
161 |
static_cast<CVcxMyVideosMdsCmdGetVideoList*>( aCmd );
|
|
162 |
iMdsDb.DoCreateVideoListL( cmd->iSortingOrder,
|
|
163 |
cmd->iAscending,
|
|
164 |
cmd->iFullDetails,
|
|
165 |
*cmd->iVideoList );
|
|
166 |
iCmdInProgress = ETrue;
|
|
167 |
}
|
|
168 |
break;
|
|
169 |
|
|
170 |
case CVcxMyVideosMdsDb::EGetAlbums:
|
|
171 |
{
|
|
172 |
CVcxMyVideosMdsCmdGetAlbums* cmd = static_cast<CVcxMyVideosMdsCmdGetAlbums*>( aCmd );
|
|
173 |
iMdsDb.iAlbums->DoGetAlbumsL( cmd->iAlbumList, *cmd->iClient );
|
|
174 |
iCmdInProgress = ETrue;
|
|
175 |
}
|
|
176 |
break;
|
|
177 |
|
|
178 |
case CVcxMyVideosMdsDb::EGetAlbumContentIds:
|
|
179 |
{
|
|
180 |
CVcxMyVideosMdsCmdGetAlbumContentIds* cmd =
|
|
181 |
static_cast<CVcxMyVideosMdsCmdGetAlbumContentIds*>( aCmd );
|
|
182 |
iMdsDb.iAlbums->DoGetAlbumContentIdsL( cmd->iAlbumId, *cmd->iAlbumContent,
|
|
183 |
*cmd->iClient );
|
|
184 |
iCmdInProgress = ETrue;
|
|
185 |
}
|
|
186 |
break;
|
|
187 |
|
|
188 |
case CVcxMyVideosMdsDb::EGetAlbumContentVideos:
|
|
189 |
{
|
|
190 |
CVcxMyVideosMdsCmdGetAlbumContentVideos* cmd =
|
|
191 |
static_cast<CVcxMyVideosMdsCmdGetAlbumContentVideos*>( aCmd );
|
|
192 |
iMdsDb.iAlbums->DoGetAlbumContentVideosL( cmd->iAlbumId, *cmd->iAlbumContentVideos,
|
|
193 |
*cmd->iClient );
|
|
194 |
iCmdInProgress = ETrue;
|
|
195 |
}
|
|
196 |
break;
|
|
197 |
|
|
198 |
case CVcxMyVideosMdsDb::EAddVideosToAlbum:
|
|
199 |
{
|
|
200 |
CVcxMyVideosMdsCmdAddVideosToAlbum* cmd =
|
|
201 |
static_cast<CVcxMyVideosMdsCmdAddVideosToAlbum*>( aCmd );
|
|
202 |
iMdsDb.iAlbums->DoAddVideosToAlbumL( cmd->iMpxCmd,
|
|
203 |
*cmd->iClient );
|
|
204 |
iCmdInProgress = ETrue;
|
|
205 |
}
|
|
206 |
break;
|
|
207 |
|
|
208 |
case CVcxMyVideosMdsDb::ERemoveRelations:
|
|
209 |
{
|
|
210 |
CVcxMyVideosMdsCmdRemoveRelations* cmd =
|
|
211 |
static_cast<CVcxMyVideosMdsCmdRemoveRelations*>( aCmd );
|
|
212 |
iMdsDb.iAlbums->DoRemoveRelationsL( *cmd->iRelationIds, *cmd->iResults,
|
|
213 |
*cmd->iClient );
|
|
214 |
iCmdInProgress = ETrue;
|
|
215 |
}
|
|
216 |
break;
|
|
217 |
|
|
218 |
case CVcxMyVideosMdsDb::ERemoveAlbums:
|
|
219 |
{
|
|
220 |
CVcxMyVideosMdsCmdRemoveAlbums* cmd =
|
|
221 |
static_cast<CVcxMyVideosMdsCmdRemoveAlbums*>( aCmd );
|
|
222 |
iMdsDb.iAlbums->DoRemoveAlbumsL( cmd->iMpxCmd, *cmd->iClient );
|
|
223 |
iCmdInProgress = ETrue;
|
|
224 |
}
|
|
225 |
break;
|
|
226 |
|
|
227 |
default:
|
|
228 |
break;
|
|
229 |
}
|
|
230 |
}
|
|
231 |
// END OF FILE
|