photosgallery/viewframework/views/viewbase/src/glxtoolbarcontroller.cpp
branchRCL_3
changeset 25 191387a8b767
parent 22 2dac0fdba72b
child 30 a60acebbbd9d
equal deleted inserted replaced
22:2dac0fdba72b 25:191387a8b767
    27 #include <mglxmedialist.h>
    27 #include <mglxmedialist.h>
    28 
    28 
    29 #include <glxnavigationalstate.h>
    29 #include <glxnavigationalstate.h>
    30 #include <mpxcollectionpath.h>
    30 #include <mpxcollectionpath.h>
    31 #include <glxcollectionpluginimageviewer.hrh>
    31 #include <glxcollectionpluginimageviewer.hrh>
    32 const TInt KGlxToolbarButtonUnLatched = 0;   // As per the states in resource file
    32 #include <centralrepository.h>              // for checking the ShareOnline version
    33 const TInt KGlxToolbarButtonLatched = 1 ;
    33 
       
    34 // CONSTANTS AND DEFINITIONS
       
    35 namespace
       
    36     {
       
    37     // ShareOnline application UID    
       
    38     const TUid KShareOnlineUid = { 0x2002CC1F };
       
    39     // Shareonline Application version
       
    40     const TUint32 KShareApplicationVersion = 0x1010020;
       
    41     // Buffer to maintain the ShareOnline version number in use
       
    42     const TInt KPhotosShareOnlineVersionBufLen = 12;
       
    43     // Minimum version required for OneClickUpload to work
       
    44     const TVersion KShareOnlineMinimumVersion( 5, 0, 0 );
       
    45     }
    34 
    46 
    35 //----------------------------------------------------------------------------------
    47 //----------------------------------------------------------------------------------
    36 // NewL
    48 // NewL
    37 //----------------------------------------------------------------------------------
    49 //----------------------------------------------------------------------------------
    38 //
    50 //
   204 //----------------------------------------------------------------------------
   216 //----------------------------------------------------------------------------
   205 //
   217 //
   206 void CGlxToolbarController::SetStatusOnViewActivationL( MGlxMediaList* aList )
   218 void CGlxToolbarController::SetStatusOnViewActivationL( MGlxMediaList* aList )
   207      {
   219      {
   208     TRACER("CGlxToolbarController::SetStatusOnViewActivationL");
   220     TRACER("CGlxToolbarController::SetStatusOnViewActivationL");
   209     GLX_LOG_INFO1("CGlxToolbarController::SetStatusOnViewActivationL(%d)",
   221     TRAPD(err, CheckShareonlineVersionL());
   210             aList->Count());
   222     GLX_LOG_INFO2("CGlxToolbarController::SetStatusOnViewActivationL(%d),"
       
   223             " err(%d)", aList->Count(), err);
       
   224 
       
   225     CGlxNavigationalState* navigationalState =
       
   226             CGlxNavigationalState::InstanceL();
       
   227     CleanupClosePushL(*navigationalState);
       
   228     if (navigationalState->ViewingMode() == NGlxNavigationalState::EBrowse)
       
   229         {
       
   230         if (err == KErrNone)
       
   231             {
       
   232             CAknButton* sendButton =
       
   233                     static_cast<CAknButton*> (iToolbar->ControlOrNull(
       
   234                             EGlxCmdSend));
       
   235             if (sendButton)
       
   236                 {
       
   237                 iToolbar->RemoveItem(EGlxCmdSend);
       
   238                 }
       
   239             }
       
   240         else
       
   241             {
       
   242             CAknButton* uploadButton =
       
   243                     static_cast<CAknButton*> (iToolbar->ControlOrNull(
       
   244                             EGlxCmdUpload));
       
   245             if (uploadButton)
       
   246                 {
       
   247                 iToolbar->RemoveItem(EGlxCmdUpload);
       
   248                 }
       
   249             }
       
   250         SetToolbarItemsDimmed(EFalse);
       
   251         }
       
   252     else if (navigationalState->ViewingMode() == NGlxNavigationalState::EView)
       
   253         {
       
   254         if (err == KErrNone)
       
   255             {
       
   256             CAknButton* slideshowButton =
       
   257                     static_cast<CAknButton*> (iToolbar->ControlOrNull(
       
   258                             EGlxCmdSlideshowPlay));
       
   259             if (slideshowButton)
       
   260                 {
       
   261                 iToolbar->RemoveItem(EGlxCmdSlideshowPlay);
       
   262                 }
       
   263             }
       
   264         else
       
   265             {
       
   266             CAknButton* uploadButton =
       
   267                     static_cast<CAknButton*> (iToolbar->ControlOrNull(
       
   268                             EGlxCmdUpload));
       
   269             if (uploadButton)
       
   270                 {
       
   271                 iToolbar->RemoveItem(EGlxCmdUpload);
       
   272                 }
       
   273             }
       
   274         SetToolbarItemsDimmed(EFalse);
       
   275         }
       
   276     CleanupStack::PopAndDestroy(navigationalState);
       
   277 
   211     // When going back from fullscreen to grid, when the attributes are already 
   278     // When going back from fullscreen to grid, when the attributes are already 
   212     // available in the cache, there is no HandleAttributeAvailable callback. Hence,
   279     // available in the cache, there is no HandleAttributeAvailable callback. Hence,
   213     // checking for medialist count.
   280     // checking for medialist count.
   214     if (!iAttributeAvailable)
   281     if (!iAttributeAvailable)
   215         {
   282         {
   237         CleanupClosePushL(*navigationalState);
   304         CleanupClosePushL(*navigationalState);
   238         if (navigationalState->ViewingMode() == NGlxNavigationalState::EView)
   305         if (navigationalState->ViewingMode() == NGlxNavigationalState::EView)
   239             {
   306             {
   240             SetToolbarItemsDimmed(EFalse);
   307             SetToolbarItemsDimmed(EFalse);
   241             }
   308             }
       
   309         else if (navigationalState->ViewingMode()
       
   310                 == NGlxNavigationalState::EBrowse)
       
   311             {
       
   312             TBool dimmed = aList->SelectionCount() ? EFalse : ETrue;
       
   313             iToolbar->SetItemDimmed(EGlxCmdSend, dimmed, ETrue);
       
   314             iToolbar->SetItemDimmed(EGlxCmdUpload, dimmed, ETrue);
       
   315             }
   242         CleanupStack::PopAndDestroy(navigationalState);
   316         CleanupStack::PopAndDestroy(navigationalState);
   243         }
   317         }
   244     }
   318     }
   245 
   319 
   246 //----------------------------------------------------------------------------
   320 //----------------------------------------------------------------------------
   251     {
   325     {
   252     CAknButton* toolbarButton = static_cast<CAknButton*>
   326     CAknButton* toolbarButton = static_cast<CAknButton*>
   253                                 (iToolbar->ControlOrNull( aCommandId ));
   327                                 (iToolbar->ControlOrNull( aCommandId ));
   254 
   328 
   255     if( toolbarButton )
   329     if( toolbarButton )
   256         {           
   330         {
   257         if(aLatched)
   331         if (aLatched)
   258             {
   332             {
   259             toolbarButton->SetCurrentState( KGlxToolbarButtonLatched, ETrue );
   333             toolbarButton->SetCurrentState(ETrue, ETrue);
   260             }
   334             }
   261         else
   335         else
   262             {
   336             {
   263             toolbarButton->SetCurrentState( KGlxToolbarButtonUnLatched, ETrue );
   337             toolbarButton->SetCurrentState(EFalse, ETrue);
   264             }
   338             }
   265         }
   339         }
   266     }
   340     }
   267 
   341 
   268 // ----------------------------------------------------------------------------
   342 // ----------------------------------------------------------------------------
   287     TRACER("CGlxToolbarController::SetToolbarItemsDimmed()");
   361     TRACER("CGlxToolbarController::SetToolbarItemsDimmed()");
   288     if (iToolbar)
   362     if (iToolbar)
   289         {
   363         {
   290         iToolbar->SetItemDimmed(EGlxCmdSlideshowPlay, aDimmed, ETrue);
   364         iToolbar->SetItemDimmed(EGlxCmdSlideshowPlay, aDimmed, ETrue);
   291         iToolbar->SetItemDimmed(EGlxCmdStartMultipleMarking, aDimmed, ETrue);
   365         iToolbar->SetItemDimmed(EGlxCmdStartMultipleMarking, aDimmed, ETrue);
   292         
   366         iToolbar->SetItemDimmed(EGlxCmdSend, aDimmed, ETrue);
   293         if (!aDimmed)
   367         iToolbar->SetItemDimmed(EGlxCmdUpload, aDimmed, ETrue);
   294             {
   368         }
   295             CAknButton* uploadButton =
   369     }
   296                     static_cast<CAknButton*> (iToolbar->ControlOrNull(
   370 
   297                             EGlxCmdUpload));
   371 // ----------------------------------------------------------------------------
   298             TBool dimmed = EFalse;
   372 // CheckShareonlineVersionL
   299             if (uploadButton)
   373 // ----------------------------------------------------------------------------
   300                 {
   374 //
   301                 // Get current button state
   375 void CGlxToolbarController::CheckShareonlineVersionL()
   302                 CAknButtonState* currentState = uploadButton->State();
   376     {
   303                 dimmed = uploadButton->IsDimmed();
   377     TRACER("CGlxToolbarController::CheckShareonlineVersionL");
   304                 iToolbar->SetItemDimmed(EGlxCmdUpload, dimmed, ETrue);
   378 
       
   379     CRepository* rep = CRepository::NewLC(KShareOnlineUid);
       
   380     //
       
   381     TBuf<KPhotosShareOnlineVersionBufLen> versionBuf;
       
   382     // Query the ShareOnline version in the build
       
   383     User::LeaveIfError(rep->Get(KShareApplicationVersion, versionBuf));
       
   384 
       
   385     // Initialize version to zero
       
   386     TVersion version(0, 0, 0);
       
   387     TLex lex(versionBuf);
       
   388     User::LeaveIfError(lex.Val(version.iMajor));
       
   389     if (lex.Get() != TChar('.'))
       
   390         {
       
   391         User::Leave(KErrCorrupt);
       
   392         }
       
   393     User::LeaveIfError(lex.Val(version.iMinor));
       
   394     if (lex.Get() != TChar('.'))
       
   395         {
       
   396         User::Leave(KErrCorrupt);
       
   397         }
       
   398     User::LeaveIfError(lex.Val(version.iBuild));
       
   399 
       
   400     // Compare version number and leave if the detected
       
   401     // version is less than KShareOnlineMinimumVersion.
       
   402     if (version.iMajor < KShareOnlineMinimumVersion.iMajor)
       
   403         {
       
   404         User::LeaveIfError(KErrNotSupported);
       
   405         }
       
   406     else if (version.iMajor == KShareOnlineMinimumVersion.iMajor)
       
   407         {
       
   408         if (version.iMinor < KShareOnlineMinimumVersion.iMinor)
       
   409             {
       
   410             User::LeaveIfError(KErrNotSupported);
       
   411             }
       
   412         else if (version.iMinor == KShareOnlineMinimumVersion.iMinor)
       
   413             {
       
   414             if (version.iBuild < KShareOnlineMinimumVersion.iBuild)
       
   415                 {
       
   416                 User::LeaveIfError(KErrNotSupported);
       
   417                 }
       
   418             else
       
   419                 {
       
   420                 // Version is supported, fall through
   305                 }
   421                 }
   306             }
   422             }
   307         else
   423         else
   308             {
   424             {
   309             iToolbar->SetItemDimmed(EGlxCmdUpload, aDimmed, ETrue);
   425             // Version is supported, fall through
   310             }
   426             }
   311         }
   427         }
       
   428     else
       
   429         {
       
   430         // Version is supported, fall through
       
   431         }
       
   432     CleanupStack::PopAndDestroy(rep);
   312     }
   433     }
   313 
   434 
   314 //end of file
   435 //end of file
   315 	
   436