bluetoothengine/btnotif/btnotifsrv/src/btnotifsettingstracker.cpp
branchRCL_3
changeset 55 613943a21004
equal deleted inserted replaced
54:0ba996a9b75d 55:613943a21004
       
     1 /*
       
     2 * Copyright (c) 2010 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: Class for tracking Bluetooth settings, and also for 
       
    15 * handling notes unrelated to specific connection.
       
    16 *
       
    17 */
       
    18 
       
    19 #include "btnotifsettingstracker.h"
       
    20 #include <btserversdkcrkeys.h>
       
    21 
       
    22 #include "btnotifserver.h"
       
    23 #include "btnotificationmanager.h"
       
    24 #include "btnotifclientserver.h"
       
    25 
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // C++ default constructor
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CBTNotifSettingsTracker::CBTNotifSettingsTracker( CBTNotifServer* aServer )
       
    34 :   iServer( aServer )
       
    35     {
       
    36     }
       
    37 
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // Symbian 2nd-phase constructor
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 void CBTNotifSettingsTracker::ConstructL()
       
    44     {
       
    45     iSettings = CBTEngSettings::NewL( this );
       
    46     User::LeaveIfError( iSettings->GetPowerState( iPowerState ) );
       
    47     }
       
    48 
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // NewL.
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CBTNotifSettingsTracker* CBTNotifSettingsTracker::NewL( CBTNotifServer* aServer )
       
    55     {
       
    56     CBTNotifSettingsTracker* self = new( ELeave ) CBTNotifSettingsTracker( aServer );
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     CleanupStack::Pop( self );
       
    60     return self;
       
    61     }
       
    62 
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Destructor
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CBTNotifSettingsTracker::~CBTNotifSettingsTracker()
       
    69     {
       
    70     if( iNotification )
       
    71         {
       
    72         // Clear the notification callback, we cannot receive them anymore.
       
    73         iNotification->RemoveObserver();
       
    74         iNotification->Close(); // Also dequeues the notification from the queue.
       
    75         iNotification = NULL;
       
    76         }
       
    77     delete iSettings;
       
    78     }
       
    79 
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // Process a client message related to notifiers.
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 void CBTNotifSettingsTracker::DispatchNotifierMessageL( const RMessage2& aMessage )
       
    86     {
       
    87     TUid uid = TUid::Uid( aMessage.Int0() );
       
    88     (void) uid;
       
    89     }
       
    90 
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // Cancels an outstanding client message related to notifiers.
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 void CBTNotifSettingsTracker::CancelNotifierMessageL( const RMessage2& aMessage )
       
    97     {
       
    98     (void) aMessage;
       
    99     }
       
   100 
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // From class MBTEngSettingsObserver.
       
   104 // Handle a power status change.
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 void CBTNotifSettingsTracker::PowerStateChanged( TBTPowerStateValue aState )
       
   108     {
       
   109     iPowerState = aState;
       
   110     TRAP_IGNORE( iServer->HandlePowerStateChangeL( aState ) );
       
   111     }
       
   112 
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // From class MBTEngSettingsObserver.
       
   116 // Handle a visibility mode change.
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CBTNotifSettingsTracker::VisibilityModeChanged( TBTVisibilityMode aState )
       
   120     {
       
   121     if( iVisibilityMode == EBTVisibilityModeTemporary && 
       
   122             aState == EBTVisibilityModeHidden && iPowerState == EBTPowerOn )
       
   123         {
       
   124         // Timeout expired, launch a note.
       
   125         // Note that we get the power state change before this one, when powering
       
   126 		// off and setting visibility mode to hidden automatically.
       
   127         NOTIF_NOTHANDLED( !iNotification )
       
   128         iNotification = iServer->NotificationManager()->GetNotification();
       
   129         if ( iNotification )
       
   130             {
       
   131             iNotification->SetObserver( this );
       
   132             iNotification->SetNotificationType( TBluetoothDeviceDialog::ENote, EVisibilityTimeout );
       
   133             TRAP_IGNORE(
       
   134                     iServer->NotificationManager()->QueueNotificationL( iNotification ) );
       
   135             }
       
   136         }
       
   137     iVisibilityMode = aState;
       
   138     }
       
   139 
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // From class MBTNotificationResult.
       
   143 // Handle a result from a user query.
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void CBTNotifSettingsTracker::MBRDataReceived( CHbSymbianVariantMap& aData )
       
   147     {
       
   148     (void) aData;
       
   149     }
       
   150 
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // From class MBTNotificationResult.
       
   154 // The notification is finished.
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 void CBTNotifSettingsTracker::MBRNotificationClosed( TInt aError, const TDesC8& aData  )
       
   158     {
       
   159     (void) aError;
       
   160     (void) aData;
       
   161     iNotification->RemoveObserver();
       
   162     iNotification = NULL;
       
   163     }