mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpsusbnotifier.h
author hgs
Fri, 23 Jul 2010 18:35:35 +0800
changeset 35 c4c427c00f31
parent 29 3ae5cb0b4c02
permissions -rw-r--r--
201029_04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     1
/*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     2
* Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     3
* All rights reserved.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     8
*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
     9
* Initial Contributors:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    11
*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    12
* Contributors:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    13
*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    14
* Description:  This class implements functions of set ptp personality, the 
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    15
*                notification of the PTP printer connection and the
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    16
*				 notification of the PTP printer disconnection. 
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    17
*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    18
*/
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    19
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    20
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    21
#ifndef DPSUSBNOTIFIER_H
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    22
#define DPSUSBNOTIFIER_H
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    23
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    24
#include <e32base.h>
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    25
#include <usbstates.h>
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    26
#include "pictbridge.h"
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    27
#include <usbman.h>
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    28
#include <usbwatcher.h>
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    29
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    30
class CDpsPtpNotifier;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    31
class CDpsConnectNotifier;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    32
class CDpsPersonalityWatcher;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    33
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    34
/**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    35
*   Class for monitoring the usb personality change and cable 
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    36
*   connection/disconnectin
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    37
*/
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    38
NONSHARABLE_CLASS(CDpsUsbNotifier) : public CActive
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    39
    {
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    40
    friend class CDpsPtpNotifier;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    41
    friend class CDpsConnectNotifier;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    42
    friend class CDpsPersonalityWatcher;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    43
	
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    44
    public:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    45
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    46
        *   Two phase constructor
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    47
        *   @param aEngine the pointer to the dps engine object
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    48
        *   @param the CDpsUsbNotifier instance 
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    49
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    50
        static CDpsUsbNotifier* NewL(CDpsEngine* aEngine);
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    51
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    52
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    53
        *   Destructor
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    54
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    55
        ~CDpsUsbNotifier();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    56
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    57
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    58
        *   Issues the request for printer connection notification
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    59
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    60
        void WaitForPrinterNotify();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    61
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    62
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    63
        *   Cancels the request for printer connection notification
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    64
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    65
        void CancelPrinterNotify();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    66
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    67
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    68
        *   Issues the request for printer connect/disconnect notification
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    69
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    70
        void ConnectNotify();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    71
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    72
		/**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    73
		*   @return TBool Checks if the PTP printer is connected
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    74
		*/		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    75
	    TBool IsConfigured() const;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    76
	    
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    77
	    /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    78
	    *
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    79
	    */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    80
	    TBool IsSetPrintModeIssued();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    81
	    
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    82
    private:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    83
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    84
        *   Second phase constructor
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    85
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    86
        void ConstructL();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    87
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    88
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    89
        *   Default constructor
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    90
        *   @param aEngine the pointer to the dps engine
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    91
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    92
        CDpsUsbNotifier(CDpsEngine *aEngine);
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    93
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    94
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    95
        *   Called by PtpNotifier to indicate a ptp printer/pc is connected
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    96
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    97
        void PtpNotify(TInt aErr);
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    98
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
    99
		/**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   100
		*
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   101
		*/
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   102
		void PersonalityChanged();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   103
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   104
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   105
        *   Called by ConnectNotifier to indeicate the cable disconnect
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   106
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   107
        void DisconnectNotify(TUsbDeviceState aState);
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   108
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   109
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   110
        *   Updates the current device state
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   111
        *   @return ETrue if OK, EFalse if failed
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   112
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   113
        TInt ConnectState();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   114
		        
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   115
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   116
        *   Changes back to the previous personality       
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   117
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   118
        void Rollback();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   119
        
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   120
    private: // from CActive		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   121
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   122
        *   @See CActive::RunL
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   123
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   124
        void RunL();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   125
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   126
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   127
        *   @See CActive::RunError
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   128
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   129
        TInt RunError(TInt aErr);
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   130
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   131
        /**
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   132
        *   @See CActive::DoCancel
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   133
        */
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   134
        void DoCancel();
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   135
		
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   136
    private:
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   137
        // not owned by this class
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   138
        CDpsEngine* iEngine;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   139
        // owned by this class
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   140
        CDpsPtpNotifier* iPtpP;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   141
        // owned by this class
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   142
        CDpsConnectNotifier* iConnectP;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   143
        // owned by this class
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   144
        CDpsPersonalityWatcher* iPersonalityWatcher;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   145
        TInt	iPersonality;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   146
        TUsbDeviceState iConnectState;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   147
        // indication of whether the PTP printer has connected
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   148
        TBool iConfigured;	
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   149
        CDpsEngine::TConnectionStatus iConnection;	
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   150
        // owned by this class
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   151
        RUsbWatcher iUsbW;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   152
        // owned by this class
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   153
        RUsb    iUsbM;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   154
        // if rollback to previous personality is needed when application quits
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   155
        TBool iRollback;
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   156
    };
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   157
3ae5cb0b4c02 201025_07
hgs
parents:
diff changeset
   158
#endif