usbservices_plat/ptp_server_api/inc/rptp.h
changeset 34 7858bc6ead78
parent 31 dfdd8240f7c8
child 35 9d8b04ca6939
equal deleted inserted replaced
31:dfdd8240f7c8 34:7858bc6ead78
     1 /*
       
     2 * Copyright (c) 2006 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:  An interface for starting PTP Server and connecting/
       
    15 *                disconnecting PTP Stack.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef  RPTP_H
       
    21 #define  RPTP_H
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 const TInt KFileExtLength = 8;
       
    26 enum TDpsPrinterState
       
    27     {
       
    28     EPrinterNotAvailable,
       
    29     EPrinterAvailable
       
    30     };
       
    31         
       
    32 
       
    33 /**
       
    34 *  RPtp class is used to create a PTP Server session and a connection to the
       
    35 *  selected transport medium.
       
    36 *
       
    37 *  @lib rptp.lib
       
    38 *  @since S60 3.2
       
    39 */
       
    40 NONSHARABLE_CLASS(RPtp) : public RSessionBase
       
    41 	{
       
    42 	
       
    43 public:
       
    44 
       
    45 	/**
       
    46 	* C++ default constructor.
       
    47 	*/
       
    48 	
       
    49 	IMPORT_C RPtp();
       
    50 	
       
    51 	/**
       
    52 	* Creates new session to PTP Server. This also register the observer
       
    53 	*  to the ptp server. This should be only used by the client other than
       
    54 	*   the Ptp CC
       
    55 	* @since S60 3.2
       
    56 	* @return KErrNone if success or system error if failed.
       
    57 	*/	
       
    58 	IMPORT_C TInt Connect();
       
    59 	
       
    60 	/**
       
    61     * Creates connection to the server and initializes the ptp stack based on
       
    62     * specified transport medium.
       
    63     * @since S60 3.2
       
    64     * @param aTransport, Implementation UID of selected transport medium.
       
    65     * 
       
    66     * @return KErrNone if success or system error if failed.
       
    67     */
       
    68 	IMPORT_C TInt CreatePtpStack( const TUid aTransport );
       
    69 	
       
    70 	/**
       
    71     * Performs DPS discovery.
       
    72     * 
       
    73     * @since S60 3.2
       
    74     * @param aStatus the result of the Dps discovery, either EAvailable or
       
    75     *   NotAvailable from TDpsPrinterState enum
       
    76     */
       
    77 	IMPORT_C void IsDpsPrinter(TRequestStatus& aStatus);
       
    78 	
       
    79 	/**
       
    80 	* Cancels previously issued Asynch request IsDpsPrinter
       
    81 	* @since S60 3.2
       
    82 	*/
       
    83 	IMPORT_C void CancelIsDpsPrinter();
       
    84 		
       
    85 	/**
       
    86 	* Client sends object and get informed when the object is received by
       
    87 	* the host. 
       
    88 	* @since S60 3.2
       
    89 	* @param aNameAndPath, the name and full path of the file.
       
    90 	* @param aAdd  Whether the ObjectAdded event should be sent out for this
       
    91 	*   object (DPS operation may require this)
       
    92 	* @param aTimeout whether the client needs the reply for this request. If
       
    93 	*   it needs the timeout will be true, which means if timout happened, 
       
    94 	*   the reply is KErrTimedout
       
    95 	* @param aStatus, Asynchronous completion word for the operation.
       
    96 	*/
       
    97 	IMPORT_C void SendObject(const TDesC& aNameAndPath, 
       
    98 	                         TRequestStatus& aStatus, TBool aTimeout,
       
    99 	                         TInt aSize, TBool aAdd = EFalse);
       
   100 	
       
   101 	/**
       
   102 	* Cancel object sending request.
       
   103 	* @since S60 3.2
       
   104 	*/
       
   105 	IMPORT_C void CancelSendObject();
       
   106 		
       
   107 	/**
       
   108 	*   Registers the certain files arrival (from the host) notification. 
       
   109 	* @since S60 3.2
       
   110 	* @param aFileExtension.  file extension
       
   111 	* @param aNameAndPath  name and path of the file.
       
   112 	* @param aDelete whether this object should be deleted after the 
       
   113 	*  notification. If it is, a ObjectRemoved event should be sent also.
       
   114 	* (Dps operation may need this)
       
   115 	* @param aStatus, Asynchronous completion word for the operation.
       
   116 	* @return None.
       
   117 	*/
       
   118 	IMPORT_C void ObjectReceivedNotify(const TDesC& aFileExtension,
       
   119 	                                   TDes& aNameAndPath, 
       
   120 	                                   TRequestStatus& aStatus,
       
   121 	                                   TBool aDelete = EFalse);
       
   122 	
       
   123 	/**
       
   124 	* Gets the object handle (whether the object exists).
       
   125 	* The client may use this function to delete certain file 
       
   126 	* (mainly for dps now)  
       
   127 	* @since S60 3.2
       
   128 	* @param aNameAndPath, A name and full path of the file.
       
   129 	* @param aHandle , 32bit handle of the object
       
   130 	* @param aAdd if this object is not find whether add it to the list
       
   131 	* @return KErrNone if object is found or KErrNotFound if not.
       
   132 	*/
       
   133 	IMPORT_C TInt GetObjectHandleByName(const TDesC& aNameAndPath, 
       
   134 	                                    TUint32& aHandle, 
       
   135 	                                    TBool aAdd = EFalse);
       
   136 	
       
   137 	/**
       
   138 	* Function 
       
   139 	* @since S60 3.2
       
   140 	* @param aNameAndPath, A name and full path of the file.
       
   141 	* @param aHandle , 32bit handle of the objcet
       
   142 	* @return KErrNone if successfull or system error if failed
       
   143 	*/
       
   144 	IMPORT_C TInt GetNameByObjectHandle(TDes& aNameAndPath, 
       
   145 	                                    const TUint32 aHandle );
       
   146 	
       
   147 	
       
   148 	/**
       
   149 	* Cancel Object received notification 
       
   150 	* @since S60 3.2
       
   151 	*/
       
   152 	IMPORT_C void CancelObjectReceivedNotify();
       
   153 	
       
   154 	/**
       
   155 	* Disconnects PTP from transport module and deletes the PTP stack.
       
   156 	* @since S60 3.2
       
   157 	* Must be only used by PTP Class Controller
       
   158 	*/		
       
   159 	IMPORT_C void DestroyPtpStatck();
       
   160 	
       
   161 	/**
       
   162 	* Returns name and path of folder
       
   163 	* @since S60 3.2 
       
   164 	* @return Folder Name and Path
       
   165 	*/
       
   166 	IMPORT_C const TDesC& PtpFolder();
       
   167     
       
   168 private:
       
   169     
       
   170     /**
       
   171     * only used by the client other than PTP Class Controller. There are only two clients
       
   172     * connects to the server at the same time. PTP Class Controller only starts and closes
       
   173     * the PTP stack.As the result not DeRegisterObserver is needed.
       
   174     * @since S60 3.2
       
   175     *   @return KErrNone if success or system error if failed
       
   176     */
       
   177     TInt RegisterObserver();    
       
   178     
       
   179 private:
       
   180     
       
   181     TBuf<KFileExtLength> iExt;
       
   182     TFileName iFile;
       
   183 	};
       
   184 	
       
   185 #endif // RPTP_H
       
   186