author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:32:09 +0300 | |
branch | RCL_3 |
changeset 75 | 01504893d9cb |
parent 68 | 5b238bc8ffb6 |
permissions | -rw-r--r-- |
60 | 1 |
/* |
2 |
* Copyright (c) 2008-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: Media item list observer interface |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
#include "glxtoolbarcontroller.h" |
|
22 |
#include <aknbutton.h> |
|
23 |
#include <akntoolbar.h> // For Toolbar |
|
24 |
#include <glxcommandhandlers.hrh> // For Command ids |
|
25 |
#include <glxtracer.h> // For Logs |
|
26 |
#include <glxlog.h> // For Logs |
|
27 |
#include <mglxmedialist.h> |
|
28 |
||
29 |
#include <glxnavigationalstate.h> |
|
30 |
#include <mpxcollectionpath.h> |
|
31 |
#include <glxcollectionpluginimageviewer.hrh> |
|
32 |
#include <centralrepository.h> // for checking the ShareOnline version |
|
33 |
#include <glxuiutility.h> |
|
34 |
||
35 |
// CONSTANTS AND DEFINITIONS |
|
36 |
namespace |
|
37 |
{ |
|
38 |
// ShareOnline application UID |
|
39 |
const TUid KShareOnlineUid = { 0x2002CC1F }; |
|
40 |
// Shareonline Application version |
|
41 |
const TUint32 KShareApplicationVersion = 0x1010020; |
|
42 |
// Buffer to maintain the ShareOnline version number in use |
|
43 |
const TInt KPhotosShareOnlineVersionBufLen = 12; |
|
44 |
// Minimum version required for OneClickUpload to work |
|
45 |
const TVersion KShareOnlineMinimumVersion( 5, 0, 0 ); |
|
46 |
} |
|
47 |
||
48 |
//---------------------------------------------------------------------------------- |
|
49 |
// NewL |
|
50 |
//---------------------------------------------------------------------------------- |
|
51 |
// |
|
52 |
CGlxToolbarController* CGlxToolbarController::NewL() |
|
53 |
{ |
|
54 |
TRACER("CGlxToolbarController::NewL"); |
|
55 |
||
56 |
CGlxToolbarController *self = new( ELeave ) CGlxToolbarController (); |
|
57 |
return self; |
|
58 |
} |
|
59 |
||
60 |
//---------------------------------------------------------------------------------- |
|
61 |
// Default Constructor |
|
62 |
//---------------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
CGlxToolbarController::CGlxToolbarController( ) |
|
65 |
{ |
|
66 |
TRACER("CGlxToolbarController::Default constructor"); |
|
67 |
||
68 |
} |
|
69 |
||
70 |
//---------------------------------------------------------------------------------- |
|
71 |
// AddToObserver |
|
72 |
//---------------------------------------------------------------------------------- |
|
73 |
// |
|
74 |
void CGlxToolbarController::AddToObserverL (MGlxMediaList& aList, CAknToolbar* aToolbar) |
|
75 |
{ |
|
76 |
TRACER("CGlxToolbarController::AddToObserverL"); |
|
77 |
||
78 |
iToolbar = aToolbar; |
|
79 |
iAttributeAvailable = EFalse; |
|
80 |
aList.AddMediaListObserverL ( this ); |
|
81 |
} |
|
82 |
||
83 |
//---------------------------------------------------------------------------------- |
|
84 |
// RemoveFromObserver |
|
85 |
//---------------------------------------------------------------------------------- |
|
86 |
// |
|
87 |
void CGlxToolbarController::RemoveFromObserver (MGlxMediaList& aList) |
|
88 |
{ |
|
89 |
TRACER("CGlxToolbarController::RemoveFromObserver"); |
|
90 |
||
91 |
if( aList.SelectionCount()<= 0 ) |
|
92 |
{ |
|
93 |
EnableLatch( EGlxCmdStartMultipleMarking, EFalse ); |
|
94 |
} |
|
95 |
||
96 |
aList.RemoveMediaListObserver ( this ); |
|
97 |
} |
|
98 |
||
99 |
//---------------------------------------------------------------------------- |
|
100 |
// HandleItemAddedL |
|
101 |
//---------------------------------------------------------------------------- |
|
102 |
// |
|
103 |
void CGlxToolbarController::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, |
|
104 |
MGlxMediaList* /*aList*/) |
|
105 |
{ |
|
106 |
TRACER("CGlxToolbarController::HandleItemAddedL"); |
|
107 |
||
108 |
} |
|
109 |
||
110 |
//---------------------------------------------------------------------------- |
|
111 |
// HandleMediaL |
|
112 |
//---------------------------------------------------------------------------- |
|
113 |
// |
|
114 |
void CGlxToolbarController::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/) |
|
115 |
{ |
|
116 |
TRACER("CGlxToolbarController::HandleMediaL"); |
|
117 |
||
118 |
} |
|
119 |
||
120 |
//---------------------------------------------------------------------------- |
|
121 |
// HandleItemRemovedL |
|
122 |
//---------------------------------------------------------------------------- |
|
123 |
// |
|
124 |
void CGlxToolbarController::HandleItemRemovedL(TInt /*aStartIndex*/, |
|
125 |
TInt /*aEndIndex*/, MGlxMediaList* aList) |
|
126 |
{ |
|
127 |
TRACER("CGlxToolbarController::HandleItemRemovedL"); |
|
128 |
||
129 |
if( aList->Count() <= 0 ) |
|
130 |
{ |
|
131 |
SetToolbarItemsDimmed(ETrue); |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
//---------------------------------------------------------------------------- |
|
136 |
// HandleItemModifiedL |
|
137 |
//---------------------------------------------------------------------------- |
|
138 |
// |
|
139 |
void CGlxToolbarController::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/, |
|
140 |
MGlxMediaList* /*aList*/) |
|
141 |
{ |
|
142 |
TRACER("CGlxToolbarController::HandleItemModifiedL"); |
|
143 |
||
144 |
} |
|
145 |
||
146 |
//---------------------------------------------------------------------------- |
|
147 |
// HandleAttributesAvailableL |
|
148 |
//---------------------------------------------------------------------------- |
|
149 |
// |
|
150 |
void CGlxToolbarController::HandleAttributesAvailableL(TInt aItemIndex, |
|
151 |
const RArray<TMPXAttribute>& /*aAttributes*/, |
|
152 |
MGlxMediaList* aList) |
|
153 |
{ |
|
154 |
TRACER("CGlxToolbarController::HandleAttributesAvailableL"); |
|
155 |
||
156 |
if( aItemIndex == aList->FocusIndex() ) |
|
157 |
{ |
|
158 |
iAttributeAvailable = ETrue; |
|
159 |
SetStatusL(aList); |
|
160 |
} |
|
161 |
} |
|
162 |
||
163 |
//---------------------------------------------------------------------------- |
|
164 |
// HandleFocusChangedL |
|
165 |
//---------------------------------------------------------------------------- |
|
166 |
// |
|
167 |
void CGlxToolbarController::HandleFocusChangedL( |
|
168 |
NGlxListDefs::TFocusChangeType /*aType*/, TInt /*aNewIndex*/, |
|
169 |
TInt /*aOldIndex*/, MGlxMediaList* aList) |
|
170 |
{ |
|
171 |
TRACER("CGlxToolbarController::HandleFocusChangedL"); |
|
172 |
if (aList->Count() <= 0) |
|
173 |
{ |
|
174 |
SetToolbarItemsDimmed(ETrue); |
|
175 |
} |
|
176 |
} |
|
177 |
||
178 |
//---------------------------------------------------------------------------- |
|
179 |
// HandleItemSelectedL |
|
180 |
//---------------------------------------------------------------------------- |
|
181 |
// |
|
182 |
void CGlxToolbarController::HandleItemSelectedL(TInt /*aIndex*/, TBool /*aSelected*/, |
|
183 |
MGlxMediaList* aList) |
|
184 |
{ |
|
185 |
TRACER("CGlxToolbarController::HandleItemSelectedL"); |
|
186 |
GLX_DEBUG2("CGlxToolbarController::HandleItemSelectedL()" |
|
187 |
" aList->SelectionCount()=%d", aList->SelectionCount()); |
|
188 |
||
189 |
// If atleast 1 item is marked, or if Mark All is called, then Latch the mark button. |
|
190 |
if ((aList->SelectionCount() == 1) || (aList->SelectionCount() |
|
191 |
== aList->Count())) |
|
192 |
{ |
|
193 |
EnableLatch(EGlxCmdStartMultipleMarking, ETrue); |
|
194 |
} |
|
195 |
} |
|
196 |
||
197 |
//---------------------------------------------------------------------------- |
|
198 |
// HandleMessageL |
|
199 |
//---------------------------------------------------------------------------- |
|
200 |
// |
|
201 |
void CGlxToolbarController::HandleMessageL(const CMPXMessage& /*aMessage*/, |
|
202 |
MGlxMediaList* /*aList*/) |
|
203 |
{ |
|
204 |
TRACER("CGlxToolbarController::HandleMessageL"); |
|
205 |
||
206 |
} |
|
207 |
||
208 |
//---------------------------------------------------------------------------- |
|
209 |
// Destructor |
|
210 |
//---------------------------------------------------------------------------- |
|
211 |
// |
|
212 |
CGlxToolbarController::~CGlxToolbarController() |
|
213 |
{ |
|
214 |
TRACER("CGlxToolbarController Destructor"); |
|
215 |
||
216 |
} |
|
217 |
||
218 |
//---------------------------------------------------------------------------- |
|
219 |
// SetStatusOnViewActivationL |
|
220 |
//---------------------------------------------------------------------------- |
|
221 |
// |
|
222 |
void CGlxToolbarController::SetStatusOnViewActivationL( MGlxMediaList* aList ) |
|
223 |
{ |
|
224 |
TRACER("CGlxToolbarController::SetStatusOnViewActivationL"); |
|
225 |
TRAPD(err, CheckShareonlineVersionL()); |
|
226 |
GLX_LOG_INFO2("CGlxToolbarController::SetStatusOnViewActivationL(%d)," |
|
227 |
" err(%d)", aList->Count(), err); |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
228 |
|
60 | 229 |
CGlxNavigationalState* navigationalState = |
230 |
CGlxNavigationalState::InstanceL(); |
|
231 |
CleanupClosePushL(*navigationalState); |
|
232 |
if (navigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) |
|
233 |
{ |
|
234 |
if (err == KErrNone) |
|
235 |
{ |
|
236 |
CAknButton* sendButton = |
|
237 |
static_cast<CAknButton*> (iToolbar->ControlOrNull( |
|
238 |
EGlxCmdSend)); |
|
239 |
if (sendButton) |
|
240 |
{ |
|
241 |
iToolbar->RemoveItem(EGlxCmdSend); |
|
242 |
} |
|
243 |
} |
|
244 |
else |
|
245 |
{ |
|
246 |
CAknButton* uploadButton = |
|
247 |
static_cast<CAknButton*> (iToolbar->ControlOrNull( |
|
248 |
EGlxCmdUpload)); |
|
249 |
if (uploadButton) |
|
250 |
{ |
|
251 |
iToolbar->RemoveItem(EGlxCmdUpload); |
|
252 |
} |
|
253 |
} |
|
254 |
iToolbar->SetItemDimmed(EGlxCmdSlideshowPlay, EFalse, ETrue); |
|
255 |
iToolbar->SetItemDimmed(EGlxCmdStartMultipleMarking, EFalse, ETrue); |
|
256 |
TBool dimmed = aList->SelectionCount() ? EFalse : ETrue; |
|
257 |
iToolbar->SetItemDimmed(EGlxCmdSend, dimmed, ETrue); |
|
258 |
iToolbar->SetItemDimmed(EGlxCmdUpload, dimmed, ETrue); |
|
259 |
} |
|
260 |
else if (navigationalState->ViewingMode() == NGlxNavigationalState::EView) |
|
261 |
{ |
|
262 |
if (err == KErrNone) |
|
263 |
{ |
|
264 |
CAknButton* slideshowButton = |
|
265 |
static_cast<CAknButton*> (iToolbar->ControlOrNull( |
|
266 |
EGlxCmdSlideshowPlay)); |
|
267 |
if (slideshowButton) |
|
268 |
{ |
|
269 |
iToolbar->RemoveItem(EGlxCmdSlideshowPlay); |
|
270 |
} |
|
271 |
} |
|
272 |
else |
|
273 |
{ |
|
274 |
CAknButton* uploadButton = |
|
275 |
static_cast<CAknButton*> (iToolbar->ControlOrNull( |
|
276 |
EGlxCmdUpload)); |
|
277 |
if (uploadButton) |
|
278 |
{ |
|
279 |
iToolbar->RemoveItem(EGlxCmdUpload); |
|
280 |
} |
|
281 |
} |
|
282 |
SetToolbarItemsDimmed(EFalse); |
|
283 |
} |
|
284 |
CleanupStack::PopAndDestroy(navigationalState); |
|
285 |
||
286 |
// When going back from fullscreen to grid, when the attributes are already |
|
287 |
// available in the cache, there is no HandleAttributeAvailable callback. Hence, |
|
288 |
// checking for medialist count. |
|
289 |
if (!iAttributeAvailable) |
|
290 |
{ |
|
291 |
SetStatusL(aList); |
|
292 |
} |
|
293 |
} |
|
294 |
||
295 |
//---------------------------------------------------------------------------- |
|
296 |
//SetStatusL |
|
297 |
//---------------------------------------------------------------------------- |
|
298 |
// |
|
299 |
void CGlxToolbarController::SetStatusL(MGlxMediaList* aList) |
|
300 |
{ |
|
301 |
TRACER("CGlxToolbarController::SetStatusL"); |
|
302 |
||
303 |
GLX_LOG_INFO1("CGlxToolbarController::SetStatusL(%d)", aList->Count()); |
|
304 |
// When going back from fullscreen to grid, when the attributes are already |
|
305 |
// available in the cache, there is no HandleAttributeAvailable callback. Hence, |
|
306 |
// checking for medialist count and backward navigation |
|
307 |
CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
|
308 |
CleanupClosePushL(*uiUtility); |
|
309 |
if (aList->Count() <= 0 && (uiUtility->ViewNavigationDirection() |
|
310 |
== EGlxNavigationBackwards)) |
|
311 |
{ |
|
312 |
SetToolbarItemsDimmed(ETrue); |
|
313 |
} |
|
314 |
else if (KErrNotFound != aList->FocusIndex()) |
|
315 |
{ |
|
316 |
CGlxNavigationalState* navigationalState = |
|
317 |
CGlxNavigationalState::InstanceL(); |
|
318 |
CleanupClosePushL(*navigationalState); |
|
319 |
if (navigationalState->ViewingMode() == NGlxNavigationalState::EView) |
|
320 |
{ |
|
321 |
SetToolbarItemsDimmed(EFalse); |
|
75
01504893d9cb
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
322 |
} |
60 | 323 |
else if (navigationalState->ViewingMode() |
324 |
== NGlxNavigationalState::EBrowse) |
|
325 |
{ |
|
326 |
TBool dimmed = aList->SelectionCount() ? EFalse : ETrue; |
|
327 |
iToolbar->SetItemDimmed(EGlxCmdSend, dimmed, ETrue); |
|
328 |
iToolbar->SetItemDimmed(EGlxCmdUpload, dimmed, ETrue); |
|
329 |
} |
|
330 |
CleanupStack::PopAndDestroy(navigationalState); |
|
331 |
} |
|
332 |
CleanupStack::PopAndDestroy(uiUtility); |
|
333 |
} |
|
334 |
||
335 |
//---------------------------------------------------------------------------- |
|
336 |
// EnableLatch |
|
337 |
//---------------------------------------------------------------------------- |
|
338 |
// |
|
339 |
void CGlxToolbarController::EnableLatch( TInt aCommandId, TInt aLatched ) |
|
340 |
{ |
|
341 |
TRACER("CGlxToolbarController::EnableLatch()"); |
|
342 |
GLX_DEBUG2("CGlxToolbarController::EnableLatch() aLatched=%d", aLatched); |
|
343 |
||
344 |
CAknButton* toolbarButton = |
|
345 |
static_cast<CAknButton*> (iToolbar->ControlOrNull(aCommandId)); |
|
346 |
||
347 |
if( toolbarButton ) |
|
348 |
{ |
|
349 |
toolbarButton->SetCurrentState(aLatched, ETrue); |
|
350 |
} |
|
351 |
} |
|
352 |
||
353 |
// ---------------------------------------------------------------------------- |
|
354 |
// HandlePopulatedL |
|
355 |
// ---------------------------------------------------------------------------- |
|
356 |
// |
|
357 |
void CGlxToolbarController::HandlePopulatedL( MGlxMediaList* aList ) |
|
358 |
{ |
|
359 |
TRACER("CGlxToolbarController::HandlePopulatedL()"); |
|
360 |
if (aList->Count() <= 0) |
|
361 |
{ |
|
362 |
SetToolbarItemsDimmed(ETrue); |
|
363 |
} |
|
364 |
if (!iToolbar->IsVisible()) |
|
365 |
{ |
|
366 |
GLX_DEBUG1("CGlxToolbarController::HandlePopulatedL()" |
|
367 |
" - SetToolbarVisibility(ETrue)"); |
|
368 |
iToolbar->SetToolbarVisibility(ETrue); |
|
369 |
} |
|
370 |
} |
|
371 |
||
372 |
// ---------------------------------------------------------------------------- |
|
373 |
// SetToolbarItemsDimmed |
|
374 |
// ---------------------------------------------------------------------------- |
|
375 |
// |
|
376 |
void CGlxToolbarController::SetToolbarItemsDimmed(TBool aDimmed) |
|
377 |
{ |
|
378 |
TRACER("CGlxToolbarController::SetToolbarItemsDimmed()"); |
|
379 |
if (iToolbar) |
|
380 |
{ |
|
381 |
iToolbar->SetItemDimmed(EGlxCmdSlideshowPlay, aDimmed, ETrue); |
|
382 |
iToolbar->SetItemDimmed(EGlxCmdStartMultipleMarking, aDimmed, ETrue); |
|
383 |
iToolbar->SetItemDimmed(EGlxCmdSend, aDimmed, ETrue); |
|
384 |
iToolbar->SetItemDimmed(EGlxCmdUpload, aDimmed, ETrue); |
|
385 |
} |
|
386 |
} |
|
387 |
||
388 |
// ---------------------------------------------------------------------------- |
|
389 |
// CheckShareonlineVersionL |
|
390 |
// ---------------------------------------------------------------------------- |
|
391 |
// |
|
392 |
void CGlxToolbarController::CheckShareonlineVersionL() |
|
393 |
{ |
|
394 |
TRACER("CGlxToolbarController::CheckShareonlineVersionL"); |
|
395 |
||
396 |
CRepository* rep = CRepository::NewLC(KShareOnlineUid); |
|
397 |
// |
|
398 |
TBuf<KPhotosShareOnlineVersionBufLen> versionBuf; |
|
399 |
// Query the ShareOnline version in the build |
|
400 |
User::LeaveIfError(rep->Get(KShareApplicationVersion, versionBuf)); |
|
401 |
||
402 |
// Initialize version to zero |
|
403 |
TVersion version(0, 0, 0); |
|
404 |
TLex lex(versionBuf); |
|
405 |
User::LeaveIfError(lex.Val(version.iMajor)); |
|
406 |
if (lex.Get() != TChar('.')) |
|
407 |
{ |
|
408 |
User::Leave(KErrCorrupt); |
|
409 |
} |
|
410 |
User::LeaveIfError(lex.Val(version.iMinor)); |
|
411 |
if (lex.Get() != TChar('.')) |
|
412 |
{ |
|
413 |
User::Leave(KErrCorrupt); |
|
414 |
} |
|
415 |
User::LeaveIfError(lex.Val(version.iBuild)); |
|
416 |
||
417 |
// Compare version number and leave if the detected |
|
418 |
// version is less than KShareOnlineMinimumVersion. |
|
419 |
if (version.iMajor < KShareOnlineMinimumVersion.iMajor) |
|
420 |
{ |
|
421 |
User::LeaveIfError(KErrNotSupported); |
|
422 |
} |
|
423 |
else if (version.iMajor == KShareOnlineMinimumVersion.iMajor) |
|
424 |
{ |
|
425 |
if (version.iMinor < KShareOnlineMinimumVersion.iMinor) |
|
426 |
{ |
|
427 |
User::LeaveIfError(KErrNotSupported); |
|
428 |
} |
|
429 |
else if (version.iMinor == KShareOnlineMinimumVersion.iMinor) |
|
430 |
{ |
|
431 |
if (version.iBuild < KShareOnlineMinimumVersion.iBuild) |
|
432 |
{ |
|
433 |
User::LeaveIfError(KErrNotSupported); |
|
434 |
} |
|
435 |
else |
|
436 |
{ |
|
437 |
// Version is supported, fall through |
|
438 |
} |
|
439 |
} |
|
440 |
else |
|
441 |
{ |
|
442 |
// Version is supported, fall through |
|
443 |
} |
|
444 |
} |
|
445 |
else |
|
446 |
{ |
|
447 |
// Version is supported, fall through |
|
448 |
} |
|
449 |
CleanupStack::PopAndDestroy(rep); |
|
450 |
} |
|
451 |
||
452 |
//end of file |
|
453 |