mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsusbnotifier.h
branchRCL_3
changeset 20 4a793f564d72
parent 19 0aa8cc770c8a
child 21 74aa6861c87d
equal deleted inserted replaced
19:0aa8cc770c8a 20:4a793f564d72
     1 /*
       
     2 * Copyright (c) 2006, 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:  This class implements functions of set ptp personality, the 
       
    15 *                notification of the PTP printer connection and the
       
    16 *				 notification of the PTP printer disconnection. 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef DPSUSBNOTIFIER_H
       
    22 #define DPSUSBNOTIFIER_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <usbstates.h>
       
    26 #include "pictbridge.h"
       
    27 #include <usbman.h>
       
    28 #include <usbwatcher.h>
       
    29 
       
    30 class CDpsPtpNotifier;
       
    31 class CDpsConnectNotifier;
       
    32 class CDpsPersonalityWatcher;
       
    33 
       
    34 /**
       
    35 *   Class for monitoring the usb personality change and cable 
       
    36 *   connection/disconnectin
       
    37 */
       
    38 NONSHARABLE_CLASS(CDpsUsbNotifier) : public CActive
       
    39     {
       
    40     friend class CDpsPtpNotifier;
       
    41     friend class CDpsConnectNotifier;
       
    42     friend class CDpsPersonalityWatcher;
       
    43 	
       
    44     public:
       
    45         /**
       
    46         *   Two phase constructor
       
    47         *   @param aEngine the pointer to the dps engine object
       
    48         *   @param the CDpsUsbNotifier instance 
       
    49         */
       
    50         static CDpsUsbNotifier* NewL(CDpsEngine* aEngine);
       
    51 		
       
    52         /**
       
    53         *   Destructor
       
    54         */
       
    55         ~CDpsUsbNotifier();
       
    56 		
       
    57         /**
       
    58         *   Issues the request for printer connection notification
       
    59         */
       
    60         void WaitForPrinterNotify();
       
    61 		
       
    62         /**
       
    63         *   Cancels the request for printer connection notification
       
    64         */
       
    65         void CancelPrinterNotify();
       
    66 		
       
    67         /**
       
    68         *   Issues the request for printer connect/disconnect notification
       
    69         */
       
    70         void ConnectNotify();
       
    71 		
       
    72 		/**
       
    73 		*   @return TBool Checks if the PTP printer is connected
       
    74 		*/		
       
    75 	    TBool IsConfigured() const;
       
    76 	    
       
    77 	    /**
       
    78 	    *
       
    79 	    */
       
    80 	    TBool IsSetPrintModeIssued();
       
    81 	    
       
    82     private:
       
    83         /**
       
    84         *   Second phase constructor
       
    85         */
       
    86         void ConstructL();
       
    87 		
       
    88         /**
       
    89         *   Default constructor
       
    90         *   @param aEngine the pointer to the dps engine
       
    91         */
       
    92         CDpsUsbNotifier(CDpsEngine *aEngine);
       
    93 		
       
    94         /**
       
    95         *   Called by PtpNotifier to indicate a ptp printer/pc is connected
       
    96         */
       
    97         void PtpNotify(TInt aErr);
       
    98 		
       
    99 		/**
       
   100 		*
       
   101 		*/
       
   102 		void PersonalityChanged();
       
   103 		
       
   104         /**
       
   105         *   Called by ConnectNotifier to indeicate the cable disconnect
       
   106         */
       
   107         void DisconnectNotify(TUsbDeviceState aState);
       
   108 		
       
   109         /**
       
   110         *   Updates the current device state
       
   111         *   @return ETrue if OK, EFalse if failed
       
   112         */
       
   113         TInt ConnectState();
       
   114 		        
       
   115         /**
       
   116         *   Changes back to the previous personality       
       
   117         */
       
   118         void Rollback();
       
   119         
       
   120     private: // from CActive		
       
   121         /**
       
   122         *   @See CActive::RunL
       
   123         */
       
   124         void RunL();
       
   125 		
       
   126         /**
       
   127         *   @See CActive::RunError
       
   128         */
       
   129         TInt RunError(TInt aErr);
       
   130 		
       
   131         /**
       
   132         *   @See CActive::DoCancel
       
   133         */
       
   134         void DoCancel();
       
   135 		
       
   136     private:
       
   137         // not owned by this class
       
   138         CDpsEngine* iEngine;
       
   139         // owned by this class
       
   140         CDpsPtpNotifier* iPtpP;
       
   141         // owned by this class
       
   142         CDpsConnectNotifier* iConnectP;
       
   143         // owned by this class
       
   144         CDpsPersonalityWatcher* iPersonalityWatcher;
       
   145         TInt	iPersonality;
       
   146         TUsbDeviceState iConnectState;
       
   147         // indication of whether the PTP printer has connected
       
   148         TBool iConfigured;	
       
   149         CDpsEngine::TConnectionStatus iConnection;	
       
   150         // owned by this class
       
   151         RUsbWatcher iUsbW;
       
   152         // owned by this class
       
   153         RUsb    iUsbM;
       
   154         // if rollback to previous personality is needed when application quits
       
   155         TBool iRollback;
       
   156     };
       
   157 
       
   158 #endif