|
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: CVcxHgMyVideosDownloadClient implementation* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <bldvariant.hrh> |
|
22 #include <mpxcollectionutility.h> |
|
23 #include <mpxcommandgeneraldefs.h> |
|
24 #include <mpxcollectioncommanddefs.h> |
|
25 #include <vcxmyvideosuids.h> |
|
26 #include <mpxmediageneraldefs.h> |
|
27 #include <vcxmyvideosdefs.h> |
|
28 #include <vcxhgmyvideos.rsg> |
|
29 #include <StringLoader.h> |
|
30 #include <aknnotewrappers.h> |
|
31 |
|
32 #include "IptvDebug.h" |
|
33 #include "vcxhgmyvideosdownloadclient.h" |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CVcxHgMyVideosDownloadClient::CVcxHgMyVideosDownloadClient() |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CVcxHgMyVideosDownloadClient::CVcxHgMyVideosDownloadClient( |
|
42 CVcxHgMyVideosCollectionClient& aCollectionClient, |
|
43 MMPXCollectionUtility& aCollectionUtility ) |
|
44 : iCollectionClient( aCollectionClient ), |
|
45 iCollectionUtility( aCollectionUtility ), |
|
46 iPendingCommand( EVcxHgMyVideosDownloadCommandNone ) |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CVcxHgMyVideosDownloadClient::NewL() |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CVcxHgMyVideosDownloadClient* CVcxHgMyVideosDownloadClient::NewL( |
|
55 CVcxHgMyVideosCollectionClient& aCollectionClient, |
|
56 MMPXCollectionUtility& aCollectionUtility ) |
|
57 { |
|
58 CVcxHgMyVideosDownloadClient* self = |
|
59 CVcxHgMyVideosDownloadClient::NewLC( aCollectionClient, aCollectionUtility ); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CVcxHgMyVideosDownloadClient::NewLC() |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CVcxHgMyVideosDownloadClient* CVcxHgMyVideosDownloadClient::NewLC( |
|
69 CVcxHgMyVideosCollectionClient& aCollectionClient, |
|
70 MMPXCollectionUtility& aCollectionUtility ) |
|
71 { |
|
72 CVcxHgMyVideosDownloadClient* self = |
|
73 new (ELeave) CVcxHgMyVideosDownloadClient( aCollectionClient, aCollectionUtility ); |
|
74 CleanupStack::PushL( self ); |
|
75 self->ConstructL(); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CVcxHgMyVideosDownloadClient::ConstructL() |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CVcxHgMyVideosDownloadClient::ConstructL() |
|
84 { |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CVcxHgMyVideosDownloadClient::~CVcxHgMyVideosDownloadClient() |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CVcxHgMyVideosDownloadClient::~CVcxHgMyVideosDownloadClient() |
|
92 { |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CVcxHgMyVideosDownloadClient::HasPendingCommand() |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TBool CVcxHgMyVideosDownloadClient::HasPendingCommand() |
|
100 { |
|
101 return iPendingCommand != EVcxHgMyVideosDownloadCommandNone; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CVcxHgMyVideosDownloadClient::ResumeDownloadL() |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CVcxHgMyVideosDownloadClient::ResumeDownloadL( const CMPXMedia& aMpxMedia ) |
|
109 { |
|
110 if ( ! HasPendingCommand() && ! iCollectionClient.HasPendingCommand() ) |
|
111 { |
|
112 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
113 CleanupStack::PushL( cmd ); |
|
114 |
|
115 CMPXMedia* media = CMPXMedia::NewL( aMpxMedia ); |
|
116 CleanupStack::PushL( media ); |
|
117 media->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 ); |
|
118 |
|
119 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
120 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosStartDownload ); |
|
121 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse ); // asynch |
|
122 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, |
|
123 TUid::Uid( KVcxUidMyVideosMpxCollection ) ); |
|
124 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, media ); |
|
125 |
|
126 iCollectionUtility.Collection().CommandL( *cmd ); |
|
127 iPendingCommand = EVcxHgMyVideosDownloadCommandResume; |
|
128 |
|
129 CleanupStack::PopAndDestroy( media ); |
|
130 CleanupStack::PopAndDestroy( cmd ); |
|
131 } |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CVcxHgMyVideosDownloadClient::CancelDownloadL() |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CVcxHgMyVideosDownloadClient::CancelDownloadL( const CMPXMedia& aMpxMedia ) |
|
139 { |
|
140 if ( ! HasPendingCommand() && ! iCollectionClient.HasPendingCommand() ) |
|
141 { |
|
142 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
143 CleanupStack::PushL( cmd ); |
|
144 |
|
145 CMPXMedia* cancelDownloadReq = CMPXMedia::NewL( aMpxMedia ); |
|
146 CleanupStack::PushL( cancelDownloadReq ); |
|
147 |
|
148 cmd->SetTObjectValueL( KMPXCommandGeneralId, KVcxCommandIdMyVideos ); |
|
149 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, KVcxCommandMyVideosCancelDownload ); |
|
150 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, EFalse ); // asynch |
|
151 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, |
|
152 TUid::Uid( KVcxUidMyVideosMpxCollection ) ); |
|
153 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq ); |
|
154 |
|
155 iCollectionUtility.Collection().CommandL( *cmd ); |
|
156 iPendingCommand = EVcxHgMyVideosDownloadCommandCancel; |
|
157 |
|
158 CleanupStack::PopAndDestroy( cancelDownloadReq ); |
|
159 CleanupStack::PopAndDestroy( cmd ); |
|
160 } |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CVcxHgMyVideosDownloadClient::CommandCompleteL() |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 void CVcxHgMyVideosDownloadClient::CommandCompleteL( TInt aError ) |
|
168 { |
|
169 if ( iPendingCommand == EVcxHgMyVideosDownloadCommandCancel && aError == KErrNone ) |
|
170 { |
|
171 // Display cancel confirmation note. |
|
172 HBufC* text = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DOWNLOAD_CANCELED ); |
|
173 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue ); |
|
174 note->ExecuteLD( *text ); |
|
175 CleanupStack::PopAndDestroy( text ); |
|
176 } |
|
177 else |
|
178 { |
|
179 // Is there need to handle failed command? |
|
180 } |
|
181 iPendingCommand = EVcxHgMyVideosDownloadCommandNone; |
|
182 } |