bluetoothcommsprofiles/btpan/panagt/panagtremdevselector.h
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef PANAGTREMOTEDEVICESELECTOR_H
       
    17 #define PANAGTREMOTEDEVICESELECTOR_H
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <e32base.h>
       
    21 #include <cdblen.h>
       
    22 #include <btextnotifiers.h>
       
    23 #include "panhelper.h"
       
    24 #include "panagtutils.h"
       
    25 #include <btextnotifierspartner.h>
       
    26 
       
    27 /**
       
    28 @file
       
    29 @note Remote device selection classes
       
    30 */
       
    31 
       
    32 class TBTDevAddr;
       
    33 class CCommsDbAccess;
       
    34 
       
    35 namespace PanAgent
       
    36 /**
       
    37 @internalComponent
       
    38 @released
       
    39 @since v8.1
       
    40 */
       
    41 {
       
    42 
       
    43 /** 
       
    44 Priority of remote device selection AO
       
    45 @internalComponent
       
    46 @see KPanAgtAoPriority
       
    47 */
       
    48 const TInt KPanAgtAoRemoteDevicePromptPriority = CActive::EPriorityStandard; 
       
    49 
       
    50 class MOutgoingConnectionCreator
       
    51 /**
       
    52 An interface to allow the outgoing connection prompter class to hand off new connections to a 
       
    53 channel manager
       
    54 @internalComponent
       
    55 */
       
    56 	{
       
    57 public:
       
    58 	/**
       
    59 	Create a new connection to the specified device
       
    60 	*/
       
    61 	virtual void CreateNewConnectionForOutgoingL(const TBTDevAddr& aRemDevAddr) = 0;
       
    62 	
       
    63 	/**
       
    64 	An error occured whilst selecting devices
       
    65 	*/
       
    66 	virtual TInt DeviceSelectionError(TInt aErr) = 0;
       
    67 	
       
    68 protected:
       
    69 	virtual ~MOutgoingConnectionCreator(){};
       
    70 	};
       
    71 	
       
    72 NONSHARABLE_CLASS(CPanRemoteDeviceSelector) : public CActive
       
    73 /**
       
    74 Find out which remote devices to connect to, either by reading addresses out of commdb, or by prompting the user
       
    75 @note This class passes the remote device addresses back to the role state machine
       
    76 @note This is one of two ways to start a connection - the other being using the Control() call on the role state machine
       
    77 @internalComponent
       
    78 */
       
    79 	{
       
    80 public:
       
    81 	CPanRemoteDeviceSelector(MOutgoingConnectionCreator& iOutgoingConnectionCreator, CCommsDbAccess& aDatabase);
       
    82 	~CPanRemoteDeviceSelector();
       
    83 	void PerformRemoteDeviceSelectionL();
       
    84 	void CreateNextConnectionL();
       
    85 	TBool IsPrompting();
       
    86 	
       
    87 	virtual void RunL();
       
    88 	virtual void DoCancel();
       
    89 	TBool HasMoreDevices();
       
    90 	void Reset();
       
    91 private:
       
    92 	TInt CreateDevicesFromUserSelection();
       
    93 	TInt DiscoverRemoteDevices(); // for when we've got a list of devices in commdb and we only want to connect to one of them
       
    94 	void ConvertListToArray(TDesC& aDeviceAddrList);
       
    95 public:
       
    96 
       
    97 private:
       
    98 	enum TRemoteDeviceSelectorState
       
    99 		{
       
   100 		ENotWaiting,				//< Not waiting for anything
       
   101 		EWaitingForNotifier,		//< Waiting for the user to respond to our remote device selection notifier
       
   102 		EWaitingForDeviceDiscovery	//< Waiting for a device discovery to complete, so we can choose a remote device
       
   103 		};
       
   104 		
       
   105 	MOutgoingConnectionCreator& iOutgoingConnectionCreator; //< The PAN agent
       
   106 	CCommsDbAccess& iDatabase;								//< Commdb access object
       
   107 	TRemoteDeviceSelectorState iState;						//< What we're waiting for in our RunL
       
   108 
       
   109 	TPckgBuf<TBTDevAddr> iRemDevAddrBuf;					//< The remote device address to which we should connect
       
   110 
       
   111 	RNotifier iNotifier; 				//< Interface to PAN remote device selection dialog
       
   112 	//Buffer received from the notifier on completion
       
   113 	TBTDeviceList iDeviceList;			
       
   114 	//This variable is introduced due to the low usability of TBTDeviceList as a devices storage
       
   115 	//TBTDeviceList doesn't have the basic operations like Count() or Remove(), but we have to use it
       
   116 	//for the notifier interface
       
   117 	RArray<TBTDevAddr> iDevAddresses;
       
   118 	
       
   119 	/**
       
   120 	If no more fixed devices available to try connecting to (we've tried all the
       
   121 	specified ones but still have no connection), prompt the user.  This is
       
   122 	different to the other 'prompt' behaviour, in that it takes place after the
       
   123 	fixed device list has been consulted rather than before.
       
   124 	*/
       
   125 	TBool iPromptIfMACFails;
       
   126 	};
       
   127 
       
   128 }	// PanAgent
       
   129 #endif // PANAGTREMOTEDEVICESELECTOR_H