ImagePrint/ImagePrintEngine/DeviceProtocols/btprotocol/inc/crsbtdiscoverengine.h
branchRCL_3
changeset 21 d59c248c9d36
parent 0 d11fb78c4374
equal deleted inserted replaced
20:159fc2f68139 21:d59c248c9d36
       
     1 /*
       
     2 * Copyright (c) 2004-2007 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:  Contains the CRsBtDiscoverEngine class definition and its observer
       
    15 * 	 		     definition (MBtDiscoveryObserver).
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CRSBTDISCOVERENGINE_H
       
    21 #define CRSBTDISCOVERENGINE_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 #include <bttypes.h>
       
    26 
       
    27 #include "imageprint.h"
       
    28 #include "cbttimer.h"
       
    29 
       
    30 class CBtDiscover;
       
    31 class CRsBtDevice;
       
    32 class CBtDeviceContainer;
       
    33 
       
    34 #define KMaxDaysForCachedDevice 30
       
    35 
       
    36 
       
    37 /**
       
    38   * \brief Observer interface for device discovery or SDP events.
       
    39   *
       
    40   * The class which owns the CRsBtDiscoverEngine object implements this interface to get
       
    41   * asynchronous notifications of Bluetooth device discovery or Service Discovery Protocol
       
    42   * events.
       
    43   */
       
    44 class MBtDiscoveryObserver
       
    45 	{
       
    46 		public:
       
    47 			// the values in this enum are subject to change as need crops up
       
    48 			// the granularity of feedback should be enough to meet UI needs
       
    49 
       
    50 			enum TEvent
       
    51 			{
       
    52 				EFoundBtPrinter,
       
    53 				ERemoveBtPrinter,
       
    54 				EDoneFindingPrinters,
       
    55 				EErrorDuringDiscover,
       
    56 				EErrorFindingDevice,
       
    57 				EErrorVerifyingBt
       
    58 			};
       
    59 		public:
       
    60 			virtual void HandleDiscoveryEvent(TInt aEvent,TInt aErrorCode)=0;
       
    61 	};
       
    62 
       
    63 /**
       
    64   * \brief Brief Description
       
    65   *
       
    66   * Detailed Description
       
    67   */
       
    68 NONSHARABLE_CLASS( CRsBtDiscoverEngine ): public CActive, public MBtTimerObserver
       
    69 	{
       
    70 		public:
       
    71 			CRsBtDevice& GetDevice();
       
    72 			~CRsBtDiscoverEngine();
       
    73 			
       
    74 			static CRsBtDiscoverEngine* NewL(MBtDiscoveryObserver& aObs);
       
    75 			void Start(TUint aRequestedProtocols);
       
    76 			void Stop();
       
    77 			
       
    78 		protected:	// from CActive
       
    79 			void DoCancel();
       
    80 			void RunL();
       
    81 			TInt RunError(TInt aError);
       
    82 
       
    83 		protected:	// from MBtTimerObserver
       
    84 			void HandleTimeoutL();
       
    85 
       
    86 		private:
       
    87 
       
    88 			CRsBtDiscoverEngine(MBtDiscoveryObserver& aObs);
       
    89 			void ConstructL();
       
    90 
       
    91 			void StartDiscovery();
       
    92 			void ContinueDiscovery();
       
    93 			
       
    94 			TBool ComposeDeviceL();
       
    95 			void ResetDevice();
       
    96 			
       
    97 			TBool CheckBtDevice();
       
    98 			
       
    99 			void ServiceDiscoveryL();
       
   100 			void StopServiceDiscovery();
       
   101 		
       
   102 		private:
       
   103 
       
   104 			enum TState
       
   105 				{
       
   106 				EFindingDevices,
       
   107 				EGettingServices,
       
   108 				EDelayFindDevices
       
   109 				};
       
   110 
       
   111 		private:
       
   112 		
       
   113 			/// State we are currently on ESendingCached, EFindingDevices, ERemovingStale, EVerifyServices, EDelayFindDevices.
       
   114 			TState iState;
       
   115 			/// This Object implements the Bluetooth Discovery system calls.
       
   116 			CBtDiscover *iDiscover;
       
   117 			/// Discovery Events observer.
       
   118 			MBtDiscoveryObserver& iObserver;
       
   119 			/// Indicates the position of the current device.
       
   120 			CRsBtDevice* iDevice;
       
   121 			
       
   122 			RArray<TBTDevAddr> iFoundBeforeArray;
       
   123 			RTimer iDelayFindDevices;
       
   124 			/// Bitmask of the protocols requested for printing.
       
   125 			TUint  iRequestedProtocols;
       
   126 			CBtTimer* iTimeout;
       
   127 	};
       
   128 
       
   129 #endif // CRSBTDISCOVERENGINE_H
       
   130 
       
   131 //  End of File