ImagePrint/ImagePrintUI/imgpprintdll/inc/cuiprotocolcontroller.h
branchRCL_3
changeset 20 159fc2f68139
parent 17 26673e532f65
child 21 d59c248c9d36
equal deleted inserted replaced
17:26673e532f65 20:159fc2f68139
     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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CUIPROTOCOLCONTROLLER_H
       
    20 #define CUIPROTOCOLCONTROLLER_H
       
    21 
       
    22 #include <e32def.h>
       
    23 #include <e32base.h>
       
    24 #include <AknProgressDialog.h>
       
    25 #include <usbman.h>
       
    26 
       
    27 #include "cdiscoverydlgmanager.h"
       
    28 #include "mprotocolobserver.h"
       
    29 #include "midleprinteventobserver.h"
       
    30 #include "imageprint.h"
       
    31 
       
    32 class CIFFactory;
       
    33 class MIdlePrintEventRegisterIF;
       
    34 class MDiscovery;
       
    35 class MPrintSettings;
       
    36 class CCustomNoteDialog;
       
    37 
       
    38 const TUint KAllBTProtocols =	KImagePrint_PrinterProtocol_BPP |
       
    39 								KImagePrint_PrinterProtocol_BIP |
       
    40 								KImagePrint_PrinterProtocol_OPP_Printer |
       
    41 								KImagePrint_PrinterProtocol_OPP_PC;
       
    42 
       
    43 //  CLASS DEFINITION
       
    44 /**
       
    45  *
       
    46  * Class searches printers(protocols) and creates print job for
       
    47  * selected printer. Class also works as an idle observer.
       
    48  *
       
    49  */
       
    50 class CUIProtocolController:
       
    51     public CBase,
       
    52     public MIdlePrintEventObserver,
       
    53     public MProgressDialogCallback
       
    54     {
       
    55     public: // Constructors and destructors
       
    56 
       
    57         /**
       
    58          *  Standard two-phase constructors
       
    59          *
       
    60          *  @param aProtocolObserver Protocol observer
       
    61          *  @param aIFFactory Interface factory class
       
    62          *
       
    63          *  @return Initialized instance of the class
       
    64          */
       
    65         IMPORT_C static CUIProtocolController* NewL( MProtocolObserver* aProtocolObserver,
       
    66                                             CIFFactory& aIFFactory );
       
    67         static CUIProtocolController* NewLC( MProtocolObserver* aProtocolObserver,
       
    68                                              CIFFactory& aIFFactory );
       
    69         /**
       
    70          * Destructor.
       
    71          */
       
    72         virtual ~CUIProtocolController();
       
    73 
       
    74     private:
       
    75 
       
    76         /**
       
    77          * Default constructor.
       
    78          *  @param aProtocolObserver Protocol observer
       
    79          *  @param aIFFactory Interface factory class
       
    80          */
       
    81         CUIProtocolController( MProtocolObserver* aProtocolObserver,
       
    82                                CIFFactory& aIFFactory );
       
    83 
       
    84      	/**
       
    85          *  Second phase constructor
       
    86          *
       
    87          *  @param aIFFactory Interface factory class
       
    88          */
       
    89      	void ConstructL( CIFFactory& aIFFactory );
       
    90 
       
    91     public: // Methods derived from MIdlePrintEventObserver
       
    92         void UsbPrinterDisconnected();
       
    93         void UsbPrinterConnected();
       
    94     	void UsbStateChanged( TImgPrintUSBState aState, TInt aError );
       
    95 		void ReadyToContinue();
       
    96 		void AsynchronousServerLeave( TInt aError );
       
    97 
       
    98     public: // Methods derived from MProgressDialogCallback
       
    99         void DialogDismissedL(TInt /*aButtonId*/ );
       
   100 
       
   101     public: // New methods
       
   102 
       
   103         /**
       
   104          * Searches default printer and takes it into use. If default
       
   105          * printer is not found full searcg is performed.
       
   106          *
       
   107          * @return ETrue if printer is succesfully taken into use
       
   108          *         EFalse in all other cases.
       
   109          */
       
   110         IMPORT_C TBool SearchDefaultPrinterL();
       
   111 
       
   112         /**
       
   113          * Searches printer with a given protocol, takes it into use
       
   114          * and sets the given protocol as a default one.
       
   115          *
       
   116          * @param aProtocol Protocol to be searched for.
       
   117          * @return ETrue if printer is succesfully taken into use
       
   118          *         EFalse in all other cases.
       
   119          */
       
   120         IMPORT_C TBool ChangeDefaultPrinterL( TInt aProtocol );
       
   121 
       
   122         /**
       
   123          * Searches for all available printers.
       
   124          * PrintJob is created after discovery with the selected
       
   125          * printer.
       
   126          *
       
   127          * @return ETrue if printer has been taken into use.
       
   128          *         EFalse in all other cases.
       
   129          */
       
   130         TBool FullSearchL();
       
   131 
       
   132     private: // New methods
       
   133 
       
   134     	TBool SetDefaultPrinterL( TInt aDefaultProtocol );
       
   135     	
       
   136         /**
       
   137          * Searches the usb printer. Method is synchronous.
       
   138          * PrintJob is created after discovery has been done.
       
   139          *
       
   140          * @return ETrue if PictBridge printer has been taken into use.
       
   141          *         EFalse in all other cases.
       
   142          */
       
   143         TBool SearchUSBPrinterL();
       
   144 
       
   145         /**
       
   146          * Takes the default BT printer into use.
       
   147          * PrintJob is created without discovery.
       
   148          *
       
   149          * @return ETrue if default BT printer has been taken into use.
       
   150          *         EFalse in all other cases.
       
   151          */
       
   152         TBool SearchDefaultBTPrinterL();
       
   153 
       
   154         /**
       
   155          * Searches for all available BT printers.
       
   156          * PrintJob is created after discovery with the selected
       
   157          * printer.
       
   158          *
       
   159          * @return ETrue if BT printer has been taken into use.
       
   160          *         EFalse in all other cases.
       
   161          */
       
   162         TBool SearchBTPrinterL();
       
   163 
       
   164         /**
       
   165          * Searches for all available UPnP(WLAN) printers.
       
   166          * PrintJob is created after discovery with the selected
       
   167          * printer.
       
   168          *
       
   169          * @return ETrue if UPnP printer has been taken into use.
       
   170          *         EFalse in all other cases.
       
   171          */
       
   172         TBool SearchUPnPPrinterL();
       
   173 
       
   174         /**
       
   175          * Takes the default UPnP(WLAN) printer into use
       
   176          * via hidden discovery
       
   177          *
       
   178          * @return ETrue if default UPnP(WLAN) printer has been taken into use.
       
   179          *         EFalse in all other cases.
       
   180          */
       
   181         TBool SearchDefaultUPnPPrinterL();
       
   182 
       
   183         /**
       
   184          * Takes the MMC into use.
       
   185          * PrintJob is created without discovery.
       
   186          *
       
   187          * @return ETrue if MMC has been taken into use.
       
   188          *         EFalse in all other cases.
       
   189          */
       
   190         TBool SearchMMCPrinterL();
       
   191 
       
   192         /**
       
   193          * Is Usb cable connected AND in PictBridge mode
       
   194          * @return ETrue if usb connected and in right mode, EFalse if not.
       
   195          */
       
   196         TBool IsUsbCableConnected();
       
   197 
       
   198         /**
       
   199          * Displays Connect USB cable -note.
       
   200          */
       
   201         void ShowConnectUsbCableNoteL();
       
   202 
       
   203     private:    // Enumerations
       
   204 
       
   205         // Different states of device discovery
       
   206         enum TClassState
       
   207             {
       
   208             ENormalState,
       
   209             EDiscoveryOngoing,
       
   210             EUSBDisconnectedDuringDiscovery
       
   211             };
       
   212 
       
   213     private: // Data
       
   214 
       
   215     	// Observer
       
   216     	MProtocolObserver* iProtocolObserver;
       
   217 
       
   218     	// Interface for registering idle observer
       
   219     	MIdlePrintEventRegisterIF* iIdleEventRegister;
       
   220 
       
   221     	// Interface for device discovery
       
   222     	MDiscovery* iDiscovery;
       
   223 
       
   224     	// Interface for settings
       
   225         MPrintSettings* iSettings;
       
   226 
       
   227         // Interface factory
       
   228         CIFFactory* iIFFactory;
       
   229 
       
   230         // USB connect note
       
   231         CCustomNoteDialog* iUSBConnectionWaitNote;
       
   232 
       
   233         // Usb manager
       
   234 		RUsb iUsbManager;
       
   235 
       
   236 		// Device state
       
   237         TUsbDeviceState iDeviceState;
       
   238 
       
   239         // Class state related to usb and discovery
       
   240         TInt iClassState;
       
   241         
       
   242         // Discovery dialog manager in case when search all protocols
       
   243         CDiscoveryDlgManager* iDiscoveryDlgManager;
       
   244         
       
   245         // tells that usb is connect during all protocols search. 
       
   246         TBool iStartUsb;
       
   247         
       
   248         // indicates that usb connection has terminated at least once
       
   249         TBool iWasUsbDisconnected;
       
   250     };
       
   251 
       
   252 #endif  // CUIPROTOCOLCONTROLLER_H
       
   253 
       
   254 //  End of File