uifw/AvKon/notifsrc/aknglobalprogressdialog.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-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 "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:  Implementation of a global progress dialog. See header file
       
    15 *                for usage example.
       
    16 *
       
    17 */
       
    18 
       
    19 #include "AknGlobalProgressDialog.h"
       
    20 #include <AknNotifyStd.h>
       
    21 #include <AknPanic.h>
       
    22 #include <s32mem.h>
       
    23 #include <AknNotifySignature.h>
       
    24 #include <aknSDData.h>
       
    25 
       
    26 const TInt KBufferGranularity = 128;
       
    27 
       
    28 EXPORT_C CAknGlobalProgressDialog* CAknGlobalProgressDialog::NewL()
       
    29     {
       
    30     CAknGlobalProgressDialog* self = NewLC();
       
    31     CleanupStack::Pop();    // self
       
    32     return self;
       
    33     }
       
    34 
       
    35 EXPORT_C CAknGlobalProgressDialog* CAknGlobalProgressDialog::NewLC()
       
    36     {
       
    37     CAknGlobalProgressDialog* self = new(ELeave) CAknGlobalProgressDialog;
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL();
       
    40     return self;
       
    41     }
       
    42 
       
    43 EXPORT_C CAknGlobalProgressDialog::~CAknGlobalProgressDialog()
       
    44     {
       
    45     iNotify.Close();
       
    46     delete iBuffer;
       
    47     delete iIconText;
       
    48     delete iIconFile;
       
    49     delete iImageFile;
       
    50     delete iAknSDData;
       
    51     }
       
    52 
       
    53 EXPORT_C void CAknGlobalProgressDialog::SetIconL( 
       
    54     const TDesC& aIconText,
       
    55     const TDesC& aIconFile,
       
    56     TInt aIconId,
       
    57     TInt aIconMaskId )
       
    58     {
       
    59     delete iIconText;
       
    60     iIconText = NULL;
       
    61     delete iIconFile;
       
    62     iIconFile = NULL;
       
    63     iIconText = aIconText.AllocL();
       
    64     iIconFile = aIconFile.AllocL();
       
    65     iIconId = aIconId;
       
    66     iIconMaskId = aIconMaskId;
       
    67     }
       
    68 
       
    69 EXPORT_C void CAknGlobalProgressDialog::SetImageL( 
       
    70     const TDesC& aImageFile,
       
    71     TInt aImageId,
       
    72     TInt aImageMaskId )
       
    73     {
       
    74     delete iImageFile;
       
    75     iImageFile = NULL;
       
    76     iImageFile = aImageFile.AllocL();
       
    77     iImageId = aImageId;
       
    78     iImageMaskId = aImageMaskId;
       
    79     }
       
    80 
       
    81 EXPORT_C void CAknGlobalProgressDialog::ShowProgressDialogL( 
       
    82     TRequestStatus& aStatus,
       
    83     const TDesC& aPrompt,
       
    84     TInt aSoftkeys,
       
    85     TInt aFinalValue,
       
    86     CAknNoteDialog::TTone aTone)
       
    87     {
       
    88     delete iBuffer;
       
    89     iBuffer = NULL;
       
    90     iBuffer = CBufFlat::NewL(KBufferGranularity);
       
    91 
       
    92     RBufWriteStream bufStream;
       
    93     bufStream.Open(*iBuffer);
       
    94 
       
    95     CleanupClosePushL(bufStream);
       
    96 
       
    97     bufStream.WriteInt32L(KAKNNOTIFIERSIGNATURE);
       
    98 
       
    99     bufStream.WriteInt32L(aSoftkeys);
       
   100     bufStream.WriteInt16L(iImageId);
       
   101     bufStream.WriteInt16L(iImageMaskId);
       
   102     bufStream.WriteInt16L(iIconId);
       
   103     bufStream.WriteInt16L(iIconMaskId);
       
   104     bufStream.WriteInt32L(aFinalValue);
       
   105     bufStream.WriteInt16L(aTone);
       
   106     bufStream.WriteInt16L(aPrompt.Length());
       
   107     if ( aPrompt.Length() )
       
   108         {
       
   109         bufStream << aPrompt;
       
   110         }
       
   111     bufStream.WriteInt16L( iImageFile ? iImageFile->Length() : 0 );
       
   112     if (iImageFile && iImageFile->Length())
       
   113         {
       
   114         bufStream << *iImageFile;
       
   115         }
       
   116     bufStream.WriteInt16L( iIconFile ? iIconFile->Length() : 0 );
       
   117     if (iIconFile && iIconFile->Length())
       
   118         {
       
   119         bufStream << *iIconFile;
       
   120         }
       
   121     bufStream.WriteInt16L( iIconText ? iIconText->Length() : 0 );
       
   122     if (iIconText && iIconText->Length())
       
   123         {
       
   124         bufStream << *iIconText;
       
   125         }
       
   126 
       
   127     bufStream.WriteInt32L(iImageSkinsMajorId);
       
   128     bufStream.WriteInt32L(iImageSkinsMinorId);
       
   129 
       
   130     bufStream.WriteInt32L(iIconSkinsMajorId);
       
   131     bufStream.WriteInt32L(iIconSkinsMinorId);
       
   132     
       
   133     if (iAknSDData)
       
   134         {
       
   135         bufStream.WriteInt8L(ETrue);
       
   136         bufStream << *iAknSDData;        
       
   137         }
       
   138     else 
       
   139         {
       
   140         bufStream.WriteInt8L(EFalse);            
       
   141         }
       
   142 
       
   143     iBufferPtr.Set(iBuffer->Ptr(0));
       
   144     iNotify.StartNotifierAndGetResponse(aStatus, KAknGlobalProgressDialogUid,
       
   145         iBufferPtr, iResultBuf);
       
   146 
       
   147     CleanupStack::PopAndDestroy();  // bufStream
       
   148     }
       
   149 
       
   150 EXPORT_C void CAknGlobalProgressDialog::UpdateProgressDialog( 
       
   151     TInt aValue, 
       
   152     TInt aFinalValue )
       
   153     {
       
   154     iCmd = EAknUpdateGlobalQuery;
       
   155     iValue = aValue;
       
   156     iFinalValue = aFinalValue;
       
   157     UpdateNotifier();
       
   158     }
       
   159 
       
   160 EXPORT_C void CAknGlobalProgressDialog::ProcessFinished()
       
   161     {
       
   162     iCmd = EAknFinishGlobalProgressDialog;
       
   163     UpdateNotifier();
       
   164     }
       
   165 
       
   166 EXPORT_C void CAknGlobalProgressDialog::CancelProgressDialog()
       
   167     {
       
   168     if (iBuffer)
       
   169         {
       
   170         iNotify.CancelNotifier(KAknGlobalProgressDialogUid );
       
   171         delete iBuffer;
       
   172         iBuffer = 0;
       
   173         }
       
   174     }
       
   175 
       
   176 void CAknGlobalProgressDialog::UpdateNotifier()
       
   177     {
       
   178     TPckgBuf<SAknNotifierPackage<SAknGlobalProgressDialogParams> > pckg;
       
   179     pckg().iParamData.iCmd = iCmd;
       
   180     pckg().iParamData.iValue = iValue;
       
   181     pckg().iParamData.iFinalValue = iFinalValue;
       
   182     TPckgBuf<TInt> ret;
       
   183     iNotify.UpdateNotifier( KAknGlobalProgressDialogUid, pckg, ret);
       
   184     }
       
   185 
       
   186 CAknGlobalProgressDialog::CAknGlobalProgressDialog()
       
   187     {
       
   188     }
       
   189 
       
   190 void CAknGlobalProgressDialog::ConstructL()
       
   191     {
       
   192     User::LeaveIfError(iNotify.Connect());
       
   193     }
       
   194 
       
   195 EXPORT_C void CAknGlobalProgressDialog::SetImageSkinIds( TAknsItemID& aImageId, 
       
   196     TAknsItemID& aIconId )
       
   197     {
       
   198     iImageSkinsMajorId = aImageId.iMajor;
       
   199     iImageSkinsMinorId= aImageId.iMinor;
       
   200 
       
   201     iIconSkinsMajorId = aIconId.iMajor;
       
   202     iIconSkinsMinorId = aIconId.iMinor;
       
   203     }
       
   204     
       
   205 EXPORT_C void CAknGlobalProgressDialog::SetSecondaryDisplayData(CAknSDData* aData)
       
   206    {
       
   207    delete iAknSDData;
       
   208    iAknSDData = aData;
       
   209    }
       
   210     
       
   211 // End of File