bluetoothengine/btnotif/src/btuserconfnotifier.cpp
author hgs
Fri, 28 May 2010 17:03:06 +0300
changeset 32 19bd632b5100
parent 26 b78e66e88238
child 35 95674584745d
permissions -rw-r--r--
201021
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  Declares User confirmation notifier for Secure Simle Pairing 
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
hgs
parents:
diff changeset
    19
// INCLUDE FILES
hgs
parents:
diff changeset
    20
#include <StringLoader.h>    // Localisation stringloader
hgs
parents:
diff changeset
    21
#include <utf.h>             // Unicode character conversion utilities
hgs
parents:
diff changeset
    22
#include <avkon.mbg>
hgs
parents:
diff changeset
    23
#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
hgs
parents:
diff changeset
    24
#include <btextnotifiers.h>
hgs
parents:
diff changeset
    25
#else
hgs
parents:
diff changeset
    26
#include <btextnotifiers.h>
hgs
parents:
diff changeset
    27
#include <btextnotifierspartner.h>
hgs
parents:
diff changeset
    28
#endif
hgs
parents:
diff changeset
    29
#include <BTNotif.rsg>       // Own resources
hgs
parents:
diff changeset
    30
#include "btnotif.hrh"       // Own resource header
hgs
parents:
diff changeset
    31
#include "btuserconfnotifier.h"  // Own class definition
hgs
parents:
diff changeset
    32
#include "btNotifDebug.h"    // Debugging macros
hgs
parents:
diff changeset
    33
#include <btotgpairpub.inl>
hgs
parents:
diff changeset
    34
#include <btengconnman.h>
26
hgs
parents: 24
diff changeset
    35
#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
24
hgs
parents:
diff changeset
    36
#include <bluetoothuiutil.h>
hgs
parents:
diff changeset
    37
#include "btnotifnameutils.h"
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
#ifdef __SERIES60_HELP
hgs
parents:
diff changeset
    40
#include <hlplch.h>
hgs
parents:
diff changeset
    41
#include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
hgs
parents:
diff changeset
    42
#endif
hgs
parents:
diff changeset
    43
hgs
parents:
diff changeset
    44
// ================= MEMBER FUNCTIONS =======================
hgs
parents:
diff changeset
    45
hgs
parents:
diff changeset
    46
// ----------------------------------------------------------
hgs
parents:
diff changeset
    47
// CBTUserConfNotifier::NewL
hgs
parents:
diff changeset
    48
// Two-phased constructor.
hgs
parents:
diff changeset
    49
// ----------------------------------------------------------
hgs
parents:
diff changeset
    50
//
hgs
parents:
diff changeset
    51
CBTUserConfNotifier* CBTUserConfNotifier::NewL()
hgs
parents:
diff changeset
    52
    {
hgs
parents:
diff changeset
    53
    CBTUserConfNotifier* self=new (ELeave) CBTUserConfNotifier();
hgs
parents:
diff changeset
    54
    CleanupStack::PushL(self);
hgs
parents:
diff changeset
    55
    self->ConstructL();
hgs
parents:
diff changeset
    56
    CleanupStack::Pop(self);
hgs
parents:
diff changeset
    57
    return self;
hgs
parents:
diff changeset
    58
    }
hgs
parents:
diff changeset
    59
hgs
parents:
diff changeset
    60
// ----------------------------------------------------------
hgs
parents:
diff changeset
    61
// CBTUserConfNotifier::CBTUserConfNotifier
hgs
parents:
diff changeset
    62
// C++ default constructor can NOT contain any code, that
hgs
parents:
diff changeset
    63
// might leave.
hgs
parents:
diff changeset
    64
// ----------------------------------------------------------
hgs
parents:
diff changeset
    65
//
hgs
parents:
diff changeset
    66
CBTUserConfNotifier::CBTUserConfNotifier()
hgs
parents:
diff changeset
    67
    {
hgs
parents:
diff changeset
    68
    
hgs
parents:
diff changeset
    69
    }
hgs
parents:
diff changeset
    70
hgs
parents:
diff changeset
    71
// ----------------------------------------------------------
hgs
parents:
diff changeset
    72
// Destructor
hgs
parents:
diff changeset
    73
// ----------------------------------------------------------
hgs
parents:
diff changeset
    74
//
hgs
parents:
diff changeset
    75
CBTUserConfNotifier::~CBTUserConfNotifier()
hgs
parents:
diff changeset
    76
    {
hgs
parents:
diff changeset
    77
    }
hgs
parents:
diff changeset
    78
hgs
parents:
diff changeset
    79
// ----------------------------------------------------------
hgs
parents:
diff changeset
    80
// CBTUserConfNotifier::RegisterL
hgs
parents:
diff changeset
    81
// Register notifier.
hgs
parents:
diff changeset
    82
// ----------------------------------------------------------
hgs
parents:
diff changeset
    83
//
hgs
parents:
diff changeset
    84
CBTUserConfNotifier::TNotifierInfo CBTUserConfNotifier::RegisterL()
hgs
parents:
diff changeset
    85
    {
hgs
parents:
diff changeset
    86
    iInfo.iUid = KBTUserConfirmationNotifierUidCopy;
hgs
parents:
diff changeset
    87
    iInfo.iChannel = KBTUserConfirmationNotifierUidCopy;
hgs
parents:
diff changeset
    88
    iInfo.iPriority=ENotifierPriorityVHigh;
hgs
parents:
diff changeset
    89
    return iInfo;
hgs
parents:
diff changeset
    90
    }
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
// ----------------------------------------------------------
hgs
parents:
diff changeset
    93
// CBTUserConfNotifier::GetParamsL
hgs
parents:
diff changeset
    94
// Initialize parameters and check if device is already
hgs
parents:
diff changeset
    95
// in registry. Jump to RunL as soon as possible.
hgs
parents:
diff changeset
    96
// ----------------------------------------------------------
hgs
parents:
diff changeset
    97
//
hgs
parents:
diff changeset
    98
void CBTUserConfNotifier::GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
hgs
parents:
diff changeset
    99
    {
hgs
parents:
diff changeset
   100
    FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::GetParamsL()"));
hgs
parents:
diff changeset
   101
hgs
parents:
diff changeset
   102
    CBTNPairNotifierBase::GetParamsL( aBuffer, aReplySlot, aMessage );
hgs
parents:
diff changeset
   103
    
hgs
parents:
diff changeset
   104
    TBTUserConfirmationParamsPckgCopy pckg;
hgs
parents:
diff changeset
   105
 	pckg.Copy(aBuffer);
hgs
parents:
diff changeset
   106
 	iBTAddr = pckg().DeviceAddress();
hgs
parents:
diff changeset
   107
    if ( OtherOutgoPairing( iBTAddr) )
hgs
parents:
diff changeset
   108
        {
hgs
parents:
diff changeset
   109
        // We won't allow incoming pairing during outgoing pairing:
hgs
parents:
diff changeset
   110
        FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier: outgoing pair in progress, reject incoming pair"));
hgs
parents:
diff changeset
   111
        CompleteMessage(KErrCancel);
hgs
parents:
diff changeset
   112
        return;
hgs
parents:
diff changeset
   113
        }
hgs
parents:
diff changeset
   114
    
hgs
parents:
diff changeset
   115
	iLocallyInitiated = pckg().LocallyInitiated(); 
hgs
parents:
diff changeset
   116
hgs
parents:
diff changeset
   117
	// base class
hgs
parents:
diff changeset
   118
	ProcessParamsGetDeviceL( iBTAddr, pckg().DeviceName() );
hgs
parents:
diff changeset
   119
	
hgs
parents:
diff changeset
   120
	FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::GetParamsL() completed"));
hgs
parents:
diff changeset
   121
    }
hgs
parents:
diff changeset
   122
hgs
parents:
diff changeset
   123
// ----------------------------------------------------------
hgs
parents:
diff changeset
   124
// CBTUserConfNotifier::HandleGetDeviceCompletedL
hgs
parents:
diff changeset
   125
// Ask user response and return it to caller.
hgs
parents:
diff changeset
   126
// Store device into registry if user has accepted pairing.
hgs
parents:
diff changeset
   127
// ----------------------------------------------------------
hgs
parents:
diff changeset
   128
//
hgs
parents:
diff changeset
   129
void CBTUserConfNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/)
hgs
parents:
diff changeset
   130
    {
hgs
parents:
diff changeset
   131
    FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL()"));
hgs
parents:
diff changeset
   132
    
hgs
parents:
diff changeset
   133
    // Check if blocked device. 
hgs
parents:
diff changeset
   134
    if( CheckBlockedDeviceL() )
hgs
parents:
diff changeset
   135
        return;
hgs
parents:
diff changeset
   136
    
hgs
parents:
diff changeset
   137
    // Turn lights on and deactivate apps -key
hgs
parents:
diff changeset
   138
    iNotifUiUtil->TurnLightsOn();
hgs
parents:
diff changeset
   139
hgs
parents:
diff changeset
   140
   	// For incoming pairing request
hgs
parents:
diff changeset
   141
    TBool answer = AuthoriseIncomingPairingL();
hgs
parents:
diff changeset
   142
    if( !answer ) 
hgs
parents:
diff changeset
   143
        {
hgs
parents:
diff changeset
   144
        //User rejects the incoming pairing, complete message in QueryBlockDevice.
hgs
parents:
diff changeset
   145
        FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL() <<"));
hgs
parents:
diff changeset
   146
        return;
hgs
parents:
diff changeset
   147
        }
hgs
parents:
diff changeset
   148
    CompleteMessage(answer, KErrNone);
hgs
parents:
diff changeset
   149
hgs
parents:
diff changeset
   150
    FLOG(_L("[BTNOTIF]\t CBTUserConfNotifier::HandleGetDeviceCompletedL() completed"));
hgs
parents:
diff changeset
   151
    }
hgs
parents:
diff changeset
   152
hgs
parents:
diff changeset
   153
// End of File