camerauis/cameraapp/generic/src/camoneclickuploadutility.cpp
branchRCL_3
changeset 12 8c55c525d5d7
parent 0 1ddebce53859
child 16 d486e5e3cc9a
equal deleted inserted replaced
11:792dfc98fb3b 12:8c55c525d5d7
    14 * Description:  Helper class for implementing one-click upload support
    14 * Description:  Helper class for implementing one-click upload support
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
       
    19 #include <gulicon.h>
       
    20 #include <akntoolbar.h>
       
    21 #include <aknbutton.h> 
       
    22 
    19 #include <AiwServiceHandler.h>
    23 #include <AiwServiceHandler.h>
    20 #include <cameraapp.rsg>
    24 #include <cameraapp.rsg>
    21 #include <vgacamsettings.rsg>
    25 #include <vgacamsettings.rsg>
    22 #include <centralrepository.h>
    26 #include <centralrepository.h>
    23 
    27 
       
    28 
    24 #include "camoneclickuploadutility.h"
    29 #include "camoneclickuploadutility.h"
    25 #include "camlogging.h"
    30 #include "camlogging.h"
    26 #include "CamPanic.h"
    31 #include "CamPanic.h"
    27 
    32 #include "Cam.hrh"
    28 const TUid KShareOnlineCrUid = { 0x2000BB53 };
    33 
       
    34 #include <cameraapp.mbg>
       
    35 #include "camutility.h"
       
    36 
       
    37 const TUid KShareOnlineCrUid = { 0x2002CC1F };
    29 const TUint32 KShareCrApplicationVersion = 0x01010020;
    38 const TUint32 KShareCrApplicationVersion = 0x01010020;
    30 const TInt KCamShareOnlineVersionBufLen = 12;
    39 const TInt KCamShareOnlineVersionBufLen = 12;
    31 const TVersion KShareOnlineMinimumVersion( 4, 3, 0 );
    40 const TVersion KShareOnlineMinimumVersion( 5, 0, 0 );
    32 const TUid KOpenModeOneClick = { 2 };
    41 const TUid KOpenModeOneClick = { 2 };
    33 const TUid KCmdGetOneClickToolTip = { 15 };
    42 const TUid KCmdGetOneClickToolTip = { 15 };
       
    43 
       
    44 const TUint32 KShareImageServiceIconFileName = 0x00000002;
       
    45 const TUint32 KShareVideoServiceIconFileName = 0x00000003;
       
    46 const TUint32 KShareCommonServiceIconFileName = 0x00000004;
    34 
    47 
    35 
    48 
    36 // ======== MEMBER FUNCTIONS ========
    49 // ======== MEMBER FUNCTIONS ========
    37 
    50 
    38 
    51 
    90 //
   103 //
    91 CCamOneClickUploadUtility::~CCamOneClickUploadUtility()
   104 CCamOneClickUploadUtility::~CCamOneClickUploadUtility()
    92     {
   105     {
    93     delete iAiwServiceHandler;
   106     delete iAiwServiceHandler;
    94     delete iTooltip;
   107     delete iTooltip;
       
   108     
       
   109     if ( iDecoder )
       
   110         delete iDecoder;
    95     }
   111     }
    96 
   112 
    97 
   113 
    98 // ---------------------------------------------------------------------------
   114 // ---------------------------------------------------------------------------
    99 // Check if one-click upload is supported
   115 // Check if one-click upload is supported
   272     __ASSERT_DEBUG( !iAiwServiceHandler, CamPanic( ECamPanicResourceLeak ) );
   288     __ASSERT_DEBUG( !iAiwServiceHandler, CamPanic( ECamPanicResourceLeak ) );
   273 
   289 
   274     iAiwServiceHandler = CAiwServiceHandler::NewL();
   290     iAiwServiceHandler = CAiwServiceHandler::NewL();
   275     iAiwServiceHandler->AttachL( R_CAM_ONE_CLICK_UPLOAD_INTEREST );
   291     iAiwServiceHandler->AttachL( R_CAM_ONE_CLICK_UPLOAD_INTEREST );
   276     }
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // Get the icon for Share AP item
       
   296 // ---------------------------------------------------------------------------
       
   297 //
       
   298 void CCamOneClickUploadUtility::CurrentIconPathL( TCamCameraMode aMode, TDes& aPath )
       
   299     {
       
   300     PRINT( _L("Camera => CCamOneClickUploadUtility::CurrentIconPathL") );
       
   301     TUint32 serviceIconId = KShareCommonServiceIconFileName;
       
   302 
       
   303     if ( ECamControllerVideo == aMode )
       
   304         {
       
   305         serviceIconId = KShareVideoServiceIconFileName;
       
   306         }
       
   307     else // image
       
   308         {
       
   309         serviceIconId = KShareImageServiceIconFileName;
       
   310         }
       
   311 
       
   312     CRepository* rep = CRepository::NewLC( KShareOnlineCrUid );
       
   313     User::LeaveIfError( rep->Get( serviceIconId, aPath ) );
       
   314     CleanupStack::PopAndDestroy( rep );
       
   315     PRINT1( _L("Camera <= CCamOneClickUploadUtility::CurrentIconPathL: %S"), &aPath );
       
   316     }
       
   317 
       
   318 // -----------------------------------------------------------------------------
       
   319 // CCamOneClickUploadUtility::UpdateUploadIcon
       
   320 // -----------------------------------------------------------------------------
       
   321 //
       
   322 void CCamOneClickUploadUtility::UpdateUploadIcon( CAknToolbar *aToolbar, 
       
   323                                                   TCamCameraMode aMode )
       
   324     {
       
   325     PRINT( _L("Camera => CCamOneClickUploadUtility::UpdateUploadIcon") );
       
   326 
       
   327     TFileName currIcon;
       
   328     CurrentIconPathL( aMode, currIcon );
       
   329 
       
   330     // If the icons are different then load the icon
       
   331     PRINT1( _L("Camera <> current icon: %S"), &iIconFileName );
       
   332     if ( currIcon.Compare(iIconFileName) != 0 )
       
   333         {
       
   334         PRINT( _L("Camera <> Decoding icon") );
       
   335         iToolbar = aToolbar;
       
   336         TRAPD( err, DecodeIconL( &currIcon ) );
       
   337         if (err)
       
   338             {
       
   339             PRINT1( _L("Camera <> CamOneClickUploadUtility - Icon decoding failed: %d"), err );
       
   340             }
       
   341         }
       
   342     else
       
   343         {
       
   344         if ( aToolbar && iIconImage )
       
   345             {
       
   346             PRINT( _L("Camera <> Copying icon") );
       
   347             CAknButton* button = dynamic_cast<CAknButton*>(
       
   348                 aToolbar->ControlOrNull( ECamCmdOneClickUpload ) );
       
   349             CAknButtonState* state = button->State();
       
   350 
       
   351             CGulIcon *icon = CGulIcon::NewL( iIconImage, iIconMask );
       
   352             state->SetIcon( icon );
       
   353             icon->SetBitmapsOwnedExternally( ETrue );
       
   354 
       
   355             button->SetButtonFlags( KAknButtonNoFrame | KAknButtonPressedDownFrame );
       
   356             aToolbar->DrawNow();
       
   357             }
       
   358         }
       
   359     PRINT( _L("Camera <= CCamOneClickUploadUtility::UpdateUploadIcon") );
       
   360     }
       
   361 
       
   362 // -----------------------------------------------------------------------------
       
   363 // CCamOneClickUploadUtility::DecodeIconL()
       
   364 // -----------------------------------------------------------------------------
       
   365 //
       
   366 void CCamOneClickUploadUtility::DecodeIconL( TDesC* aPath )
       
   367     {
       
   368     PRINT1( _L("Camera => CCamOneClickUploadUtility::DecodeIconL: %S"), aPath );
       
   369 
       
   370     if ( !iDecoder )
       
   371         {
       
   372         iDecoder = CCamImageDecoder::NewL( *this );
       
   373         }
       
   374     iDecoder->StartIconConversionL( aPath );
       
   375 
       
   376     // Mark the given file as the icon in use when decoding has started
       
   377     iIconFileName.Copy( *aPath );
       
   378 
       
   379     PRINT( _L("Camera <= CCamOneClickUploadUtility::DecodeIconL") );
       
   380     }
       
   381 
       
   382 // ---------------------------------------------------------------------------
       
   383 // Image decoding complete notification
       
   384 // ---------------------------------------------------------------------------
       
   385 //
       
   386 void CCamOneClickUploadUtility::ImageDecoded( TInt aStatus, const CFbsBitmap* aBitmap, const CFbsBitmap* aMask )
       
   387     {
       
   388     PRINT( _L("Camera => CCamOneClickUploadUtility::ImageDecoded") );
       
   389 
       
   390     if ( aStatus == KErrNone )
       
   391         {
       
   392         delete iIconImage;
       
   393         delete iIconMask;
       
   394         
       
   395         iIconImage = new (ELeave) CFbsBitmap;
       
   396         iIconImage->Duplicate( aBitmap->Handle() );
       
   397 
       
   398         if ( aMask )
       
   399             {
       
   400             iIconMask = new (ELeave) CFbsBitmap;
       
   401             iIconMask->Duplicate( aMask->Handle() );
       
   402             }
       
   403     
       
   404         if ( iToolbar )
       
   405             {
       
   406             PRINT( _L("Displaying icon") );
       
   407             
       
   408             CAknButton* uploadButton =
       
   409                         static_cast<CAknButton*> (iToolbar->ControlOrNull(ECamCmdOneClickUpload));
       
   410             CAknButtonState* currentState = uploadButton->State();
       
   411 
       
   412             CGulIcon *icon =  CGulIcon::NewL( iIconImage, iIconMask );
       
   413             icon->SetBitmapsOwnedExternally( ETrue );
       
   414             currentState->SetIcon( icon );
       
   415 
       
   416             uploadButton->SetButtonFlags( KAknButtonNoFrame | KAknButtonPressedDownFrame );
       
   417             iToolbar->DrawNow();
       
   418             }
       
   419         }
       
   420     else
       
   421         {
       
   422         PRINT1( _L("Camera <> CCamOneClickUploadUtility::ImageDecoded - err:%d"), aStatus );
       
   423         }
       
   424 
       
   425     PRINT( _L("Camera <= CCamOneClickUploadUtility::ImageDecoded") );
       
   426     }