localconnectivityservice/obexsendservices/obexservicesendutils/src/BTSUPassKeyRequest.cpp
changeset 0 c3e98f10fcf4
equal deleted inserted replaced
-1:000000000000 0:c3e98f10fcf4
       
     1 /*
       
     2 * Copyright (c) 2002 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:  CBTSUPasskeyRequest implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "BTSUPassKeyRequest.h"
       
    21 #include "BTSUDebug.h"
       
    22 #include "BTServiceUtils.h"
       
    23 
       
    24 #include <utf.h>
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CBTSUPasskeyRequest::CBTSUPasskeyRequest
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CBTSUPasskeyRequest::CBTSUPasskeyRequest() : CActive(EPriorityNormal)
       
    35     {
       
    36     CActiveScheduler::Add( this );
       
    37     }
       
    38 
       
    39 // Destructor
       
    40 CBTSUPasskeyRequest::~CBTSUPasskeyRequest()
       
    41     {
       
    42     FLOG(_L("[BTSU]\t CBTSUPasskeyRequest::~CBTSUPasskeyRequest"));
       
    43 
       
    44     Cancel(); // Make sure we're cancelled
       
    45     iNotif.Close();
       
    46 
       
    47     FLOG(_L("[BTSU]\t CBTSUPasskeyRequest:~CBTSUPasskeyRequest completed"));
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CBTSUPasskeyRequest::DoCancel()
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 void CBTSUPasskeyRequest::DoCancel()
       
    55     {
       
    56     FLOG(_L("[BTSU]\t CBTSUPasskeyRequest::DoCancel"));
       
    57 
       
    58     iNotif.CancelNotifier( KBTObexPasskeyQueryNotifierUid );
       
    59     iNotif.Close();
       
    60 
       
    61     FLOG(_L("[BTSU]\t CBTSUPasskeyRequest::DoCancel completed"));
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CBTSUPasskeyRequest::RunL()
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 void CBTSUPasskeyRequest::RunL()
       
    69     {
       
    70     FTRACE(FPrint(_L( "[BTSU]\t CBTSUPasskeyRequest::RunL status %d"), iStatus.Int() ));
       
    71 
       
    72     if ( iStatus.Int() == KErrNone )
       
    73         {
       
    74         TBuf<KBTObexPasskeyMaxLength> tempResultBuffer;
       
    75         CnvUtfConverter::ConvertToUnicodeFromUtf8( tempResultBuffer, iObexPasskey() );
       
    76         iObexClient->UserPasswordL( tempResultBuffer );
       
    77 
       
    78         FTRACE(FPrint(_L("[BTSU]\t CBTSUPasskeyRequest::RunL user entered '%S'"), &tempResultBuffer ));
       
    79         }
       
    80     else
       
    81         {
       
    82         iObexClient->Error( KErrCancel );
       
    83         }
       
    84 
       
    85     iNotif.CancelNotifier( KBTObexPasskeyQueryNotifierUid );
       
    86     iNotif.Close();
       
    87 
       
    88     FLOG(_L("[BTSU]\t CBTSUPasskeyRequest::RunL completed"));
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CBTSUPasskeyRequest::RunError()
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 TInt CBTSUPasskeyRequest::RunError()
       
    96     {
       
    97     FLOG(_L("[BTSU]\t CBTSUPasskeyRequest::RunError"));
       
    98 
       
    99     iNotif.CancelNotifier( KBTObexPasskeyQueryNotifierUid );
       
   100     iNotif.Close();
       
   101     return KErrNone;
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CBTSUPasskeyRequest::StartPassKeyRequestL()
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CBTSUPasskeyRequest::StartPassKeyRequestL( CObexClient* aObexClient )
       
   109     {
       
   110     FLOG(_L("[BTSU]\t CBTSUPasskeyRequest::StartPassKeyRequestL"));
       
   111     __ASSERT_DEBUG( aObexClient != NULL, BTSUPanic( EBTSUPanicNullPointer ) );
       
   112 
       
   113     User::LeaveIfError( iNotif.Connect() );
       
   114     TPtrC8 dummy( KNullDesC8 );
       
   115 
       
   116     // Starts notifier and gets the passkey for Obex
       
   117     iNotif.StartNotifierAndGetResponse( iStatus, KBTObexPasskeyQueryNotifierUid, dummy, iObexPasskey );
       
   118     iObexClient = aObexClient;
       
   119     SetActive();
       
   120 
       
   121     FLOG(_L("[BTSU]\t CBTSUPasskeyRequest::StartPassKeyRequestL completed"));
       
   122     }
       
   123 
       
   124 //  End of File