bluetoothengine/btnotif/btnotifsrv/inc/btnotifdeviceselector.h
branchRCL_3
changeset 56 9386f31cc85b
parent 55 613943a21004
child 61 269724087bed
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : btnotifdeviceselector.h
       
     4 *  Part of     : BTProximity / BTProximity
       
     5 *  Description : Class for tracking Bluetooth settings, and also for 
       
     6 *                handling notes unrelated to specific connection.
       
     7 *
       
     8 *  Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     9 *  All rights reserved.
       
    10 *  This component and the accompanying materials are made available
       
    11 *  under the terms of "Eclipse Public License v1.0"
       
    12 *  which accompanies this distribution, and is available
       
    13 *  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    14 *
       
    15 *  Initial Contributors:
       
    16 *  Nokia Corporation - initial contribution.
       
    17 *
       
    18 *  Contributors:
       
    19 *  Nokia Corporation
       
    20 * ============================================================================
       
    21 * Template version: 4.2
       
    22 */
       
    23 
       
    24 #ifndef BTNOTIFDEVICESELECTOR_H
       
    25 #define BTNOTIFDEVICESELECTOR_H
       
    26 
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <btengsettings.h>
       
    30 #include <btservices/devdiscoveryobserver.h>
       
    31 #include "bluetoothnotification.h"
       
    32 #include <btservices/btdevrepository.h>
       
    33 #include <hb/hbcore/hbsymbianvariant.h>
       
    34 
       
    35 class CBTNotifServer;
       
    36 class CAdvanceDevDiscoverer;
       
    37 class CBtDevExtension;
       
    38 
       
    39 /**
       
    40  *  ?one_line_short_description
       
    41  *  ?more_complete_description
       
    42  *
       
    43  *  @code
       
    44  *   ?good_class_usage_example(s)
       
    45  *  @endcode
       
    46  *
       
    47  *  @lib ?library
       
    48  *  @since S60 ?S60_version *** for example, S60 v3.0
       
    49  */
       
    50 NONSHARABLE_CLASS( CBTNotifDeviceSelector ) : 
       
    51         public CBase,
       
    52         public MBTNotificationResult,
       
    53         public MDevDiscoveryObserver,
       
    54         public MBtDevRepositoryObserver
       
    55     {
       
    56 
       
    57 public:
       
    58 
       
    59     /**
       
    60      * Two-phased constructor.
       
    61      * @param aServer Pointer to our parent
       
    62      */
       
    63     static CBTNotifDeviceSelector* NewL( CBTNotifServer& aServer );
       
    64 
       
    65     /**
       
    66     * Destructor.
       
    67     */
       
    68     virtual ~CBTNotifDeviceSelector();
       
    69 
       
    70     /**
       
    71      * Processes a message from a notifier client related to settings.
       
    72      *
       
    73      * @since Symbian^4
       
    74      * @param aMessage The message containing the details of the client request.
       
    75      */
       
    76     void DispatchNotifierMessageL( const RMessage2& aMessage );
       
    77 
       
    78     /**
       
    79      * Cancels an oustanding message from a notifier client related to settings.
       
    80      *
       
    81      * @since Symbian^4
       
    82      * @param aMessage The message containing the details of the original client request.
       
    83      */
       
    84     void CancelNotifierMessageL( const RMessage2& aMessage );
       
    85 
       
    86 private:
       
    87 // from base class MBTNotificationResult
       
    88 
       
    89     /**
       
    90      * From MBTNotificationResult.
       
    91      * Handle an intermediate result from a user query.
       
    92      * This ffunction is called if the user query passes information
       
    93      * back before it has finished i.e. is dismissed. The final acceptance/
       
    94      * denial of a query is passed back in MBRNotificationClosed.
       
    95      *
       
    96      * @since Symbian^4
       
    97      * @param aData the returned data. The actual format 
       
    98      *              is dependent on the actual notifier.
       
    99      */
       
   100     virtual void MBRDataReceived( CHbSymbianVariantMap& aData );
       
   101 
       
   102     /**
       
   103      * From MBTNotificationResult.
       
   104      * The notification is finished. The resulting data (e.g. user input or
       
   105      * acceptance/denial of the query) is passed back here.
       
   106      *
       
   107      * @since Symbian^4
       
   108      * @param aErr KErrNone or one of the system-wide error codes.
       
   109      * @param aData the returned data. The actual format 
       
   110      *              is dependent on the actual notifier.
       
   111      */
       
   112     virtual void MBRNotificationClosed( TInt aError, const TDesC8& aData );
       
   113     
       
   114     // From MDevDiscoveryObserver
       
   115     
       
   116     /**
       
   117      * Callback to notify that a device has been found.
       
   118      *
       
   119      * @param aAddr the inquiry address that contains the inquiry information
       
   120      *  of the found device.
       
   121      * @param aName the Bluetooth device name of the found device
       
   122      */
       
   123     virtual void HandleNextDiscoveryResultL( 
       
   124             const TInquirySockAddr& aAddr, const TDesC& aName );
       
   125     
       
   126     /**
       
   127      * Callback to notify that the device search has completed.
       
   128      *
       
   129      * @param aErr the error code of device search result.
       
   130      */
       
   131     virtual void HandleDiscoveryCompleted( TInt aErr );
       
   132     
       
   133     
       
   134     // From MBtDeviceRepositoryObserver
       
   135     
       
   136     void RepositoryInitialized();
       
   137     
       
   138     void DeletedFromRegistry( const TBTDevAddr& addr );
       
   139     
       
   140     void AddedToRegistry( const CBtDevExtension& dev );
       
   141     
       
   142     void ChangedInRegistry( const CBtDevExtension& dev, TUint similarity  ); 
       
   143 
       
   144     void ServiceConnectionChanged(
       
   145             const CBtDevExtension& dev, TBool connected );
       
   146 
       
   147     
       
   148 private:
       
   149 
       
   150     CBTNotifDeviceSelector( CBTNotifServer& aServer );
       
   151 
       
   152     void ConstructL();
       
   153     
       
   154     void PrepareNotificationL( 
       
   155             TBluetoothDialogParams::TBTDialogType aType,
       
   156             TBTDialogResourceId aResourceId );
       
   157 			
       
   158 	void LoadUsedDevicesL();	
       
   159 	
       
   160 	void AddDataL(CHbSymbianVariantMap* aMap, const TDesC& aKey, const TAny* aData, 
       
   161 	        CHbSymbianVariant::TType aDataType);
       
   162 	
       
   163 	void setMajorProperty(TInt aMajorProperty, TInt prop, TBool addto);
       
   164 	
       
   165 	TBool isBonded( const CBTDevice &dev );
       
   166 	
       
   167 	CBtDevExtension* GetDeviceFromRepositoryL( const TBTDevAddr& addr );
       
   168 	
       
   169 	void SendSelectedDeviceL( CHbSymbianVariantMap& aData );
       
   170     
       
   171 private: // data    
       
   172 
       
   173     /**
       
   174      * Reference to our parent the server class.
       
   175      * Not own.
       
   176      */
       
   177     CBTNotifServer& iServer;
       
   178     
       
   179     /**
       
   180      * Pointer to an outstanding user interaction.
       
   181      * Not own.
       
   182      */
       
   183     CBluetoothNotification* iNotification;
       
   184     
       
   185     /**
       
   186      * device inquiry handler:
       
   187      */
       
   188     CAdvanceDevDiscoverer* iDiscoverer;
       
   189     
       
   190     /**
       
   191      *  own's the elements in the array.
       
   192      */
       
   193     RDevExtensionArray iDevices;
       
   194     
       
   195     /**
       
   196      * The message for a pending device selection request from a RNotifier client.
       
   197      */
       
   198     RMessage2 iMessage;
       
   199     
       
   200     TBool iRepositoryInitialized;
       
   201     
       
   202     TBool iLoadDevices;
       
   203     
       
   204     };
       
   205 
       
   206 #endif // BTNOTIFDEVICESELECTOR_H