bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp
branchRCL_3
changeset 55 613943a21004
parent 54 0ba996a9b75d
child 56 9386f31cc85b
equal deleted inserted replaced
54:0ba996a9b75d 55:613943a21004
     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:  Declares OBEX PIN query notifier class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <utf.h>                // Unicode character conversion utilities
       
    21 
       
    22 #include <BTNotif.rsg>          // Own resources
       
    23 #include "btnobexpinnotifier.h" // Own class definition
       
    24 #include "btNotifDebug.h"       // Debugging macros
       
    25 
       
    26 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // ----------------------------------------------------------
       
    31 // CBTObexPinNotifier::NewL
       
    32 // Two-phased constructor.
       
    33 // ----------------------------------------------------------
       
    34 //
       
    35 CBTObexPinNotifier* CBTObexPinNotifier::NewL()
       
    36     {
       
    37     CBTObexPinNotifier* self=new (ELeave) CBTObexPinNotifier();
       
    38     CleanupStack::PushL(self);
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop();
       
    41     return self;
       
    42     }
       
    43 
       
    44 // ----------------------------------------------------------
       
    45 // CBTObexPinNotifier::CBTObexPinNotifier
       
    46 // C++ default constructor can NOT contain any code, that
       
    47 // might leave.
       
    48 // ----------------------------------------------------------
       
    49 //
       
    50 CBTObexPinNotifier::CBTObexPinNotifier()
       
    51     {
       
    52     }
       
    53 
       
    54 // ----------------------------------------------------------
       
    55 // Destructor
       
    56 // ----------------------------------------------------------
       
    57 //
       
    58 CBTObexPinNotifier::~CBTObexPinNotifier()
       
    59     {
       
    60     }
       
    61 
       
    62 // ----------------------------------------------------------
       
    63 // CBTObexPinNotifier::RegisterL
       
    64 // ----------------------------------------------------------
       
    65 //
       
    66 CBTObexPinNotifier::TNotifierInfo CBTObexPinNotifier::RegisterL()
       
    67     {
       
    68     iInfo.iUid=KBTObexPasskeyQueryNotifierUid;
       
    69     iInfo.iChannel=KBTObexPINChannel;
       
    70     iInfo.iPriority=ENotifierPriorityVHigh;
       
    71     return iInfo;
       
    72     }
       
    73 
       
    74 // ----------------------------------------------------------
       
    75 // CBTObexPinNotifier::GetParamsL
       
    76 // Initialize parameters. Jump to RunL as soon as possible.
       
    77 // ----------------------------------------------------------
       
    78 //
       
    79 void CBTObexPinNotifier::GetParamsL(const TDesC8& /* aBuffer */, TInt aReplySlot, const RMessagePtr2& aMessage)
       
    80     {
       
    81     FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::GetParamsL()"));
       
    82 
       
    83     if( !iMessage.IsNull())
       
    84         {
       
    85         User::Leave(KErrInUse);
       
    86         }
       
    87 
       
    88     iMessage = aMessage;
       
    89     iReplySlot = aReplySlot;
       
    90 
       
    91     if ( AutoLockOnL() )
       
    92         {
       
    93         // The phone is locked, access denied.
       
    94         //
       
    95         CompleteMessage(KErrCancel);
       
    96         return;
       
    97         }
       
    98  
       
    99     ShowNoteCompleteMessageL();
       
   100 
       
   101     FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::GetParamsL() completed"));
       
   102     }
       
   103 
       
   104 // ----------------------------------------------------------
       
   105 // CBTObexPinNotifier::ShowNoteCompleteMessageL
       
   106 // Ask user response and return it to caller.
       
   107 // ----------------------------------------------------------
       
   108 //
       
   109 void CBTObexPinNotifier::ShowNoteCompleteMessageL()
       
   110     {
       
   111     FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::ShowNoteCompleteMessageL()"));
       
   112 
       
   113     TBuf<KBTObexPasskeyMaxLength> tempPasskeyBuffer;    // Unicode buffer
       
   114 
       
   115     TInt keypress = iNotifUiUtil->ShowTextInputQueryL( tempPasskeyBuffer, 
       
   116             R_BT_OBEX_PASSKEY_QUERY, ECmdShowBtOpenCoverNote );
       
   117 		
       
   118     if( keypress ) // OK pressed
       
   119         {
       
   120         // Convert data from unicode to 8 bit and write it back to caller
       
   121         //
       
   122         TBTObexPasskey obexPasskey;
       
   123         obexPasskey.Zero();
       
   124         CnvUtfConverter::ConvertFromUnicodeToUtf8(obexPasskey, tempPasskeyBuffer);
       
   125         CompleteMessage(TPckgBuf<TBTObexPasskey>(obexPasskey), KErrNone);
       
   126         }
       
   127     else  // Cancel pressed
       
   128         {
       
   129         CompleteMessage(KErrCancel);
       
   130         }	
       
   131 
       
   132     FLOG(_L("[BTNOTIF]\t CBTObexPinNotifier::ShowNoteCompleteMessageL() completed"));
       
   133     }
       
   134 
       
   135 
       
   136 // End of File