pkiutilities/CTSecurityDialogs/ClientSrc/SecurityDialogBase.cpp
changeset 0 164170e6151a
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2003 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 the CSecurityDialogBase class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "SecurityDialogBase.h"
       
    21 #include <s32mem.h>
       
    22 
       
    23 // EXTERNAL DATA STRUCTURES
       
    24 
       
    25 // EXTERNAL FUNCTION PROTOTYPES  
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // MACROS
       
    30 
       
    31 // LOCAL CONSTANTS AND MACROS
       
    32 
       
    33 // MODULE DATA STRUCTURES
       
    34 
       
    35 // LOCAL FUNCTION PROTOTYPES
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CSecurityDialogBase::CSecurityDialogBase
       
    44 // C++ default constructor can NOT contain any code, that
       
    45 // might leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CSecurityDialogBase::CSecurityDialogBase()
       
    49     {
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CSecurityDialogBase::ConstructL
       
    54 // Symbian 2nd phase constructor can leave.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CSecurityDialogBase::ConstructL()
       
    58     {
       
    59     iRequester = CCTSecurityDialogRequestor::NewL( *this );
       
    60     iSenderBuffer = CBufFlat::NewL( KCTSecDialSendBufLen );
       
    61     }
       
    62 
       
    63     
       
    64 // Destructor
       
    65 CSecurityDialogBase::~CSecurityDialogBase()
       
    66     {
       
    67     if ( iRequester )
       
    68         {
       
    69 		iRequester->Cancel();
       
    70         }
       
    71 	delete iRequester;
       
    72     delete iSenderBuffer;
       
    73     delete iBufferData; 
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CSecurityDialogBase::HandleResponse
       
    78 // HandleResponse handles the dialog Requestor's responses to dialogs 
       
    79 // and updates the client component's variables.
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CSecurityDialogBase::HandleResponse( TInt aResult )
       
    83     {
       
    84 	User::RequestComplete(iClientStatus, aResult);
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CSecurityDialogBase::InitClientStatus
       
    89 // InitClientStatus initialises the client's RequestStatus object.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CSecurityDialogBase::InitClientStatus( TRequestStatus& aStatus )
       
    93 	{
       
    94 	iClientStatus = &aStatus;
       
    95 	*iClientStatus = KRequestPending;
       
    96 	}
       
    97 // -----------------------------------------------------------------------------
       
    98 // CSecurityDialogBase::ShowNoteL
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 
       
   102 void CSecurityDialogBase::ShowNoteL(
       
   103                             TRequestStatus& aStatus, 
       
   104                             TInt aDlgType,  
       
   105                             const TDesC& aDynamic)
       
   106     {
       
   107 
       
   108 	InitClientStatus( aStatus );
       
   109 	
       
   110 	iSenderBuffer->Reset();
       
   111 	RBufWriteStream stream;
       
   112 	CleanupClosePushL( stream );
       
   113 	stream.Open( *iSenderBuffer );
       
   114 
       
   115 	stream.WriteInt32L( aDlgType );
       
   116 	stream.WriteInt32L( aDynamic.Length() );
       
   117 	stream << aDynamic;
       
   118 
       
   119 	stream.WriteInt32L(0);
       
   120 	stream << KNullDesC;
       
   121 
       
   122     delete iBufferData;
       
   123     iBufferData = NULL;
       
   124 	iBufferData = HBufC8::NewL(iSenderBuffer->Ptr(0).Size());
       
   125 	iBufferData->Des() = iSenderBuffer->Ptr(0);
       
   126 	CleanupStack::PopAndDestroy(); // stream.close;
       
   127 
       
   128 	RequestDialog(*iBufferData);
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CSecurityDialogBase::RequestDialog
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CSecurityDialogBase::RequestDialog(const TDesC8& aData)
       
   136     {
       
   137     iRequester->RequestDialog(aData, iDlgResponseBuf);
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CSecurityDialogBase::Requester
       
   142 // -----------------------------------------------------------------------------
       
   143 //    
       
   144 CCTSecurityDialogRequestor& CSecurityDialogBase::Requester()
       
   145     {
       
   146     return *iRequester;
       
   147     }
       
   148 // -----------------------------------------------------------------------------
       
   149 // CSecurityDialogBase::CheckError
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 void CSecurityDialogBase::CheckError( TInt aError )
       
   153     {
       
   154     if (aError)
       
   155         {
       
   156         User::RequestComplete(iClientStatus, aError);
       
   157         }
       
   158     }
       
   159 
       
   160 //  End of File