bluetoothengine/btnotif/btnotifsrv/src/bluetoothnotification.cpp
author hgs
Fri, 03 Sep 2010 16:17:59 +0300
changeset 57 5ebadcda06cb
parent 42 b72428996822
child 70 f5508c13dfe0
permissions -rw-r--r--
201035_7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
     1
/*
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
     3
* All rights reserved.
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
     4
* This component and the accompanying materials are made available
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
     6
* which accompanies this distribution, and is available
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
     8
*
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
     9
* Initial Contributors:
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
    10
* Nokia Corporation - initial contribution.
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    11
*
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
    12
* Contributors:
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    13
*
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
    14
* Description: Description: Class for managing an actual user notification or query.
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
    15
*              It hides UI framework-specifics in a private class.
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
    16
*
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    17
*/
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    18
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    19
#include "bluetoothnotification.h"
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    20
#include <hb/hbcore/hbsymbianvariant.h>
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    21
#include "btnotificationmanager.h"
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    22
#include "btnotifserver.h"
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    23
#include "bluetoothtrace.h"
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    24
#include <utf.h>  // for debugging
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    25
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    26
/**  Identifier of Bluetooth device dialog plug-in. */
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    27
_LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    28
/**  Key name of result. */
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    29
_LIT( KBTDevDialogResult, "result" );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    30
_LIT( KBTDevDialogInput, "input" );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    31
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    32
enum TDialogState
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    33
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    34
    EWaitingForClosing,
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    35
    };
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    36
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    37
// ======== MEMBER FUNCTIONS ========
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    38
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    39
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    40
// C++ default constructor
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    41
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    42
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    43
CBluetoothNotification::CBluetoothNotification( CBTNotificationManager* aManager )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    44
:   iManager( aManager )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    45
    {
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    46
    iActive = NULL;
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    47
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    48
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    49
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    50
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    51
// Symbian 2nd-phase constructor
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    52
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    53
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    54
void CBluetoothNotification::ConstructL()
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    55
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    56
    iNotificationData = CHbSymbianVariantMap::NewL();
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    57
    iDialog = CHbDeviceDialogSymbian::NewL();
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    58
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    59
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    60
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    61
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    62
// NewL.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    63
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    64
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    65
CBluetoothNotification* CBluetoothNotification::NewL( 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    66
    CBTNotificationManager* aManager )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    67
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    68
	BOstraceFunctionEntry0( DUMMY_DEVLIST );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    69
    CBluetoothNotification* self = new( ELeave ) CBluetoothNotification( aManager );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    70
    CleanupStack::PushL( self );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    71
    self->ConstructL();
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    72
    CleanupStack::Pop( self );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    73
	BOstraceFunctionExit0( DUMMY_DEVLIST );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    74
    return self;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    75
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    76
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    77
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    78
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    79
// Destructor
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    80
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    81
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    82
CBluetoothNotification::~CBluetoothNotification()
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    83
{
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    84
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    85
    if(iActive)
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    86
        {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    87
        if(iActive->IsActive())
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    88
            {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    89
            iActive->Cancel();
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    90
            }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    91
        delete iActive;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    92
        }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
    93
    iClosingTimer.Close();
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    94
    delete iDialog;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    95
    delete iNotificationData;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    96
    delete iReturnData;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    97
	BOstraceFunctionExit1( DUMMY_DEVLIST, this )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    98
}
48ae3789ce00 201017_2
hgs
parents:
diff changeset
    99
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   100
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   101
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   102
// Creates new notification data.
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   103
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   104
//
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   105
CHbSymbianVariantMap* CBluetoothNotification::CreateNotificationDataL()
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   106
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   107
    if(iNotificationData!=NULL)
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   108
        {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   109
        delete iNotificationData;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   110
        iNotificationData = NULL;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   111
        }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   112
    iNotificationData = CHbSymbianVariantMap::NewL();
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   113
    return iNotificationData;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   114
    }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   115
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   116
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   117
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   118
// Sets the data to be shown to the user.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   119
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   120
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   121
TInt CBluetoothNotification::SetData( TInt aDataType, const TDesC& aData )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   122
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   123
    TRAPD( err, SetDataL( aDataType, aData ) );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   124
    return (int) err;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   125
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   126
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   127
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   128
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   129
// Sets the data to be shown to the user.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   130
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   131
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   132
TInt CBluetoothNotification::SetData( TInt aDataType, TInt aData )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   133
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   134
    TRAPD( err, SetDataL( aDataType, aData ) );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   135
    return (int) err;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   136
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   137
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   138
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   139
// Updates the data to be shown to the user.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   140
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   141
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   142
TInt CBluetoothNotification::Update( const TDesC& aData )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   143
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   144
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   145
    TRAPD(ret,UpdateDataL( TBluetoothDeviceDialog::EDeviceName, aData ));
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   146
    if(!ret)
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   147
        {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   148
            int ret = iDialog->Update( *iNotificationData );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   149
        }
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   150
    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   151
    return ret;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   152
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   153
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   154
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   155
// Updates the data to be shown to the user.
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   156
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   157
//
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   158
TInt CBluetoothNotification::Update( TInt aData )
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   159
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   160
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   161
    TRAPD(ret,UpdateDataL( TBluetoothDeviceDialog::EAdditionalInt, aData ));
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   162
    if(!ret)
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   163
        {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   164
            ret = iDialog->Update( *iNotificationData );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   165
        }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   166
    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   167
    return ret;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   168
    }
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   169
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   170
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   171
// Show the notification, which means that it is added to the queue.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   172
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   173
//
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   174
void CBluetoothNotification::ShowL()
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   175
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   176
	BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   177
    SetDataL( TBluetoothDialogParams::EDialogType, iType );
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   178
    SetDataL( TBluetoothDialogParams::EResource, iResourceId );
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   179
    delete iReturnData;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   180
    iReturnData = NULL;
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   181
    iReturnData = CHbSymbianVariantMap::NewL();
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   182
    iDialog->Show( KBTDevDialogId(), *iNotificationData, this );
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   183
    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   184
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   185
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   186
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   187
// Stop showing the notification.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   188
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   189
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   190
TInt CBluetoothNotification::Close()
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   191
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   192
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   193
    iDialog->Cancel();
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   194
    iManager->ReleaseNotification( this );
42
hgs
parents: 31
diff changeset
   195
	BOstraceFunctionExit0( DUMMY_DEVLIST );
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   196
    return KErrNone;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   197
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   198
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   199
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   200
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   201
// Sets the data to be shown to the user.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   202
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   203
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   204
void CBluetoothNotification::SetDataL( TInt aType, const TDesC& aData )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   205
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   206
    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   207
    TBuf16<6> key;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   208
    CHbSymbianVariant* value = NULL;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   209
    switch( aType )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   210
        {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   211
        case TBluetoothDialogParams::EAddress:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   212
        case TBluetoothDeviceDialog::EDeviceName:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   213
        case TBluetoothDeviceDialog::EAdditionalDesc:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   214
        case TBluetoothDialogParams::EDialogTitle:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   215
            key.Num(aType);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   216
            value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EDes );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   217
			BtTraceBlock( 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   218
                    TBuf<32> buf;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   219
                    switch (aType) {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   220
                        case TBluetoothDialogParams::EAddress:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   221
                            _LIT(KAddress,"EAddress");
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   222
                            buf.Append(KAddress); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   223
                            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   224
                        case TBluetoothDeviceDialog::EDeviceName:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   225
                            _LIT(KDeviceName,"EDeviceName");
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   226
                            buf.Append(KDeviceName); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   227
                            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   228
                        case TBluetoothDeviceDialog::EAdditionalDesc:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   229
                            _LIT(KAdditionalDesc,"EAdditionalDesc");
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   230
                            buf.Append(KAdditionalDesc); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   231
                            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   232
                    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   233
                    TPtrC p(buf);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   234
                    TPtrC16 *ptr = (TPtrC16 *)value->Data();
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   235
                    BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%S]", &p, ptr);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   236
                    );
42
hgs
parents: 31
diff changeset
   237
            User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   238
            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   239
        case TBluetoothDialogParams::EResource:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   240
        case TBluetoothDeviceDialog::EDeviceClass:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   241
        case TBluetoothDeviceDialog::EAdditionalInt:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   242
            PanicServer( EBTNotifPanicBadArgument );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   243
            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   244
        case TBluetoothDialogParams::ENoParams:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   245
        case TBluetoothDeviceDialog::ENoParams:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   246
        default:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   247
            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   248
        }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   249
		BOstraceFunctionExit1( DUMMY_DEVLIST, this );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   250
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   251
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   252
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   253
// Sets the data to be shown to the user.
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   254
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   255
//
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   256
void CBluetoothNotification::SetDataL( TInt aType, TInt aData )
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   257
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   258
    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   259
    TBuf<6> key;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   260
    CHbSymbianVariant* value = NULL;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   261
    switch( aType )
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   262
        {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   263
        case TBluetoothDialogParams::EDialogType:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   264
        case TBluetoothDialogParams::EResource:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   265
        case TBluetoothDialogParams::EDialogTitle:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   266
        case TBluetoothDeviceDialog::EDeviceClass:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   267
        case TBluetoothDeviceDialog::EAdditionalInt:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   268
            key.Num(aType);
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   269
            value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EInt );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   270
            BtTraceBlock( 
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   271
                    TBuf<32> buf;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   272
                    switch (aType) {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   273
                        case TBluetoothDialogParams::EDialogType:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   274
                            buf = _L("EDialogType"); 
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   275
                            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   276
                        case TBluetoothDialogParams::EResource:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   277
                            buf = _L("EResource");
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   278
                            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   279
                        case TBluetoothDeviceDialog::EDeviceClass:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   280
                            buf = _L("EDeviceClass");
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   281
                            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   282
                        case TBluetoothDeviceDialog::EAdditionalInt:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   283
                            buf = _L("EAdditionalInt");
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   284
                            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   285
                    }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   286
                    TPtrC p(buf);
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   287
                    TInt *intPtr = (TInt *)value->Data();
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   288
                    BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%d]", &p, *intPtr);
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   289
                    );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   290
            User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   291
            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   292
        case TBluetoothDialogParams::EAddress:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   293
        case TBluetoothDeviceDialog::EDeviceName:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   294
            PanicServer( EBTNotifPanicBadArgument );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   295
            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   296
        case TBluetoothDialogParams::ENoParams:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   297
        case TBluetoothDeviceDialog::ENoParams:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   298
        default:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   299
            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   300
        }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   301
        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   302
    }
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   303
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   304
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   305
// Sets the data to be shown to the user.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   306
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   307
//
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   308
void CBluetoothNotification::UpdateDataL( TInt aType, const TDesC& aData )
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   309
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   310
    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   311
    TBuf16<6> key;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   312
    CHbSymbianVariant* value = NULL;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   313
    switch( aType )
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   314
        {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   315
        case TBluetoothDialogParams::EAddress:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   316
        case TBluetoothDeviceDialog::EDeviceName:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   317
        case TBluetoothDeviceDialog::EAdditionalDesc:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   318
        case TBluetoothDialogParams::EDialogTitle:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   319
            key.Num(aType);
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   320
            value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EDes );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   321
            BtTraceBlock( 
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   322
                    TBuf<32> buf;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   323
                    switch (aType) {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   324
                        case TBluetoothDialogParams::EAddress:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   325
                            _LIT(KAddress,"EAddress");
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   326
                            buf.Append(KAddress); 
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   327
                            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   328
                        case TBluetoothDeviceDialog::EDeviceName:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   329
                            _LIT(KDeviceName,"EDeviceName");
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   330
                            buf.Append(KDeviceName); 
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   331
                            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   332
                        case TBluetoothDeviceDialog::EAdditionalDesc:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   333
                            _LIT(KAdditionalDesc,"EAdditionalDesc");
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   334
                            buf.Append(KAdditionalDesc); 
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   335
                            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   336
                    }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   337
                    TPtrC p(buf);
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   338
                    TPtrC16 *ptr = (TPtrC16 *)value->Data();
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   339
                    BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%S]", &p, ptr);
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   340
                    );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   341
            User::LeaveIfError(iNotificationData->Delete( key));
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   342
            User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   343
            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   344
        case TBluetoothDialogParams::EResource:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   345
        case TBluetoothDeviceDialog::EDeviceClass:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   346
        case TBluetoothDeviceDialog::EAdditionalInt:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   347
            PanicServer( EBTNotifPanicBadArgument );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   348
            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   349
        case TBluetoothDialogParams::ENoParams:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   350
        case TBluetoothDeviceDialog::ENoParams:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   351
        default:
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   352
            break;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   353
        }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   354
        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   355
    }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   356
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   357
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   358
// Sets the data to be shown to the user.
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   359
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   360
//
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   361
void CBluetoothNotification::UpdateDataL( TInt aType, TInt aData )
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   362
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   363
    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   364
    TBuf<6> key;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   365
    CHbSymbianVariant* value = NULL;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   366
    switch( aType )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   367
        {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   368
        case TBluetoothDialogParams::EDialogType:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   369
        case TBluetoothDialogParams::EResource:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   370
        case TBluetoothDialogParams::EDialogTitle:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   371
        case TBluetoothDeviceDialog::EDeviceClass:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   372
        case TBluetoothDeviceDialog::EAdditionalInt:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   373
            key.Num(aType);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   374
            value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EInt );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   375
			BtTraceBlock( 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   376
                    TBuf<32> buf;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   377
                    switch (aType) {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   378
                        case TBluetoothDialogParams::EDialogType:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   379
                            buf = _L("EDialogType"); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   380
                            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   381
                        case TBluetoothDialogParams::EResource:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   382
                            buf = _L("EResource");
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   383
                            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   384
                        case TBluetoothDeviceDialog::EDeviceClass:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   385
                            buf = _L("EDeviceClass");
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   386
                            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   387
                        case TBluetoothDeviceDialog::EAdditionalInt:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   388
                            buf = _L("EAdditionalInt");
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   389
                            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   390
                    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   391
                    TPtrC p(buf);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   392
                    TInt *intPtr = (TInt *)value->Data();
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   393
                    BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%d]", &p, *intPtr);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   394
                    );
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   395
			User::LeaveIfError(iNotificationData->Delete(key));
42
hgs
parents: 31
diff changeset
   396
			User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   397
            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   398
        case TBluetoothDialogParams::EAddress:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   399
        case TBluetoothDeviceDialog::EDeviceName:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   400
            PanicServer( EBTNotifPanicBadArgument );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   401
            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   402
        case TBluetoothDialogParams::ENoParams:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   403
        case TBluetoothDeviceDialog::ENoParams:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   404
        default:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   405
            break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   406
        }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   407
		BOstraceFunctionExit1( DUMMY_DEVLIST, this );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   408
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   409
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   410
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   411
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   412
// From class MHbDeviceDialogObserver.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   413
// Callback called when data is received from a device dialog.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   414
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   415
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   416
void CBluetoothNotification::DataReceived( CHbSymbianVariantMap& aData )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   417
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   418
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   419
    BtTraceBlock( debugHbSymbianVariantMap(aData); );
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   420
    CHbSymbianVariant* value = NULL;
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   421
    for( TInt i = 0; i < aData.Keys().MdcaCount(); i++ )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   422
        {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   423
        TPtrC key( aData.Keys().MdcaPoint( i ).Ptr(), aData.Keys().MdcaPoint( i ).Length() );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   424
        const CHbSymbianVariant* valueRef = aData.Get( key );
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   425
        value = NULL;
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   426
        TRAP_IGNORE( value = 
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   427
                CHbSymbianVariant::NewL( valueRef->Data(), valueRef->Type() ) );
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   428
        if ( value )
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   429
            {
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   430
            TInt err = iReturnData->Add( key, value );
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   431
            if ( err ) 
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   432
                {
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   433
                // todo: better exception handing than ignoring this failure?
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   434
                }
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   435
            }
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   436
        }
42
hgs
parents: 31
diff changeset
   437
    if( iObserver )
hgs
parents: 31
diff changeset
   438
        {
hgs
parents: 31
diff changeset
   439
    	iObserver->MBRDataReceived( aData );
hgs
parents: 31
diff changeset
   440
        }
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   441
    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   442
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   443
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   444
#ifdef BLUETOOTHTRACE_ENABLED
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   445
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   446
void CBluetoothNotification::debugHbSymbianVariantMap( CHbSymbianVariantMap& aData)
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   447
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   448
    for( TInt i = 0; i < aData.Keys().MdcaCount(); i++ )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   449
        {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   450
        TBuf<128> buf;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   451
        TPtrC key( aData.Keys().MdcaPoint( i ).Ptr(), aData.Keys().MdcaPoint( i ).Length() );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   452
        buf = key;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   453
        buf.Append(_L(" = "));
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   454
        const CHbSymbianVariant* value = aData.Get( key );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   455
        TBuf<16> nbr;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   456
        TBuf<32> newBuf;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   457
        switch (value->Type()) {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   458
            case CHbSymbianVariant::EInt :
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   459
                buf.Append(_L("[EInt] ")); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   460
                nbr.Num(*((TInt*)value->Data()));
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   461
                buf.Append(nbr);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   462
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   463
            case  CHbSymbianVariant::EBool :
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   464
                buf.Append(_L("[EBool] ")); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   465
                buf.Append(*((TBool*)value->Data()) ? _L("True") : _L("False"));
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   466
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   467
            case CHbSymbianVariant::EUint :
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   468
                buf.Append( _L("[EUint] ")); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   469
                nbr.Num(*((TUint*)value->Data()));
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   470
                buf.Append(nbr);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   471
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   472
            case CHbSymbianVariant::EReal  :
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   473
                buf.Append(_L("[EReal] ")); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   474
                nbr.Num(*((TReal*)value->Data()));
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   475
                buf.Append(nbr);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   476
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   477
            case CHbSymbianVariant::EDes :  // TDesC
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   478
                buf.Append(_L("[EDes] ")); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   479
                buf.Append(*((TPtrC16 *)value->Data()));
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   480
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   481
            case CHbSymbianVariant::EBinary :  // TDesC8
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   482
                buf.Append(_L("[EBinary] ")); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   483
                // the following function caused problems when converting this function to 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   484
                // a trace function in bluetoothtrace.h
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   485
                CnvUtfConverter::ConvertToUnicodeFromUtf8(newBuf,*((TPtrC8 *)value->Data()) );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   486
                buf.Append(newBuf);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   487
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   488
            case CHbSymbianVariant::EChar  : // a TChar
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   489
                buf.Append(_L("[EChar] ")); 
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   490
                buf.Append(*((TChar *)value->Data()));
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   491
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   492
            case CHbSymbianVariant::ERect  : // a TRect
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   493
            case CHbSymbianVariant::EPoint : // a TPoint
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   494
            case CHbSymbianVariant::ESize  : // a TSize
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   495
            case CHbSymbianVariant::EDesArray : //  a MDesCArray
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   496
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   497
            default:
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   498
                break;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   499
            }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   500
        TPtrC p(buf);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   501
        BOstraceExt1( TRACE_DEBUG, DUMMY_DEVLIST, "HbSymbianVariantMap [%S]", &p);
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   502
        }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   503
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   504
#endif // BLUETOOTHTRACE_ENABLED
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   505
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   506
// From class MHbDeviceDialogObserver.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   507
// Callback called when a device dialog is closed.
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   508
// ---------------------------------------------------------------------------
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   509
//
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   510
void CBluetoothNotification::DeviceDialogClosed( TInt aCompletionCode )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   511
    {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   512
    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aCompletionCode );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   513
    TPckg<TBool> result( EFalse );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   514
    TPtrC8 resultPtr( result );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   515
    const CHbSymbianVariant* value = iReturnData->Get( KBTDevDialogResult );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   516
    if( value && value->IsValid() )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   517
        {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   518
        result() = *value->Value<TBool>();
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   519
        }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   520
    RBuf8 resultBuf;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   521
    value = iReturnData->Get( KBTDevDialogInput );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   522
    if( value && value->IsValid() )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   523
        {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   524
        HBufC8* data = value->Value<HBufC8>();
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   525
        if( !resultBuf.Create( data->Length() + result.Length() ) )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   526
            {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   527
            resultBuf = *data;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   528
            resultBuf.Insert( 0, result );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   529
            resultPtr.Set( resultBuf );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   530
            }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   531
        }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   532
    if( iObserver )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   533
        {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   534
        if( aCompletionCode == CHbDeviceDialogSymbian::ECancelledError )
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   535
            {
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   536
            aCompletionCode = KErrCancel;
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   537
            }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   538
        iObserver->MBRNotificationClosed( aCompletionCode, resultPtr );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   539
        }
31
a0ea99b6fa53 201019_1
hgs
parents: 29
diff changeset
   540
    resultBuf.Close();
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   541
    iManager->ReleaseNotification( this );
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   542
    // Note that we might get deleted after releasing ourselves.
42
hgs
parents: 31
diff changeset
   543
    BOstraceFunctionExit0( DUMMY_DEVLIST );
29
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   544
    }
48ae3789ce00 201017_2
hgs
parents:
diff changeset
   545
57
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   546
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   547
// Activate a timer which will automatically close the dialog when expired.
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   548
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   549
//
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   550
void CBluetoothNotification::SetCloseTimer(TInt aAfter)
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   551
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   552
    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aAfter );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   553
    TRAP_IGNORE(iActive = CBtSimpleActive::NewL(*this, EWaitingForClosing ));
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   554
    User::LeaveIfError( iClosingTimer.CreateLocal() );
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   555
    iClosingTimer.After(iActive->iStatus, aAfter);
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   556
    iActive->GoActive();
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   557
    }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   558
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   559
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   560
// From MBtSimpleActiveObserver
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   561
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   562
//
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   563
void CBluetoothNotification::RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus )
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   564
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   565
    (void)aActive;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   566
    (void)aStatus;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   567
    Close();
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   568
    }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   569
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   570
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   571
// From MBtSimpleActiveObserver
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   572
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   573
//
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   574
void CBluetoothNotification::CancelRequest( TInt aRequestId )
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   575
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   576
    (void)aRequestId;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   577
    // ignore    
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   578
    }
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   579
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   580
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   581
// From MBtSimpleActiveObserver
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   582
// ---------------------------------------------------------------------------
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   583
//
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   584
void CBluetoothNotification::HandleError( CBtSimpleActive* aActive, TInt aError )
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   585
    {
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   586
    (void)aActive;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   587
    (void)aError;
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   588
    // ignore
5ebadcda06cb 201035_7
hgs
parents: 42
diff changeset
   589
    }