mtpdataproviders/mtppictbridgedp/pictbridgeengine/inc/dpstransaction.h
changeset 28 85e0c0339cc3
equal deleted inserted replaced
25:48a2e0d8a4ce 28:85e0c0339cc3
       
     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 creates and parses dps operations. 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef DPSTRANSACTION_H
       
    20 #define DPSTRANSACTION_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "dpsdefs.h"
       
    24 #include "dpsoperation.h"
       
    25 
       
    26 class 	CDpsFile;
       
    27 class 	CDpsEngine;
       
    28 class   CDpsXmlGenerator;
       
    29 class	CDpsXmlParser;
       
    30 class 	CDpsScriptSender;
       
    31 class   TDpsVersion;
       
    32 class   CDpsStateMachine;
       
    33 class   TMDpsOperation;
       
    34 
       
    35 /**
       
    36 *   This class creates and parses dps operation (request and reply)
       
    37 */
       
    38 NONSHARABLE_CLASS(CDpsTransaction) : public CBase
       
    39     {
       
    40     public:
       
    41         /**
       
    42         *   Two phase constructor
       
    43         *   
       
    44         *   @param iOperator the pointer to dps operation object
       
    45         *   @return the dps transaction instance
       
    46         */
       
    47         static CDpsTransaction* NewL(CDpsStateMachine* iOperator);    
       
    48 
       
    49         /**
       
    50         *   Destructor
       
    51         */        							 
       
    52         ~CDpsTransaction();
       
    53         
       
    54     public:
       
    55         /**
       
    56         *   Creates the dps operation request
       
    57         *   @param aParam the dps operation parameters
       
    58         */
       
    59     	void CreateRequestL(TMDpsOperation* aOperation);
       
    60     	
       
    61     	/**
       
    62     	*   Parses dps operation script
       
    63     	*   @param aReply if the script is the reply from the host
       
    64     	*   aReply is ETrue, otherwise the script must be the request
       
    65     	*   from the device and aReply is EFalse
       
    66     	*/
       
    67     	void ParseScriptL(TBool aReply);
       
    68     	
       
    69     	/**
       
    70     	*   @return ETrue if the script is the reply from the host,
       
    71     	*   EFalse if the script is the request from the host
       
    72     	*/
       
    73     	inline TBool IsReply();
       
    74     	
       
    75     	/**
       
    76     	*   @return the CDpsXmlParser object
       
    77     	*/
       
    78     	inline CDpsXmlParser* Parser();
       
    79     	    
       
    80     	/**
       
    81     	*   @return the CDpsXmlGenerator object
       
    82     	*/
       
    83     	inline CDpsXmlGenerator* Generator();    
       
    84     	    
       
    85     	/**
       
    86     	*   @return the CDpsEngine object
       
    87     	*/    
       
    88         inline CDpsEngine* Engine();
       
    89     	
       
    90     	    					 
       
    91 		/**
       
    92     	*   Converts the version in descriptor tpye to TDpsVersion type
       
    93     	*   @param aParser the version in descriptor 
       
    94     	*   @param aVersoin the version in TDpsVersion and will be returned
       
    95     	*   @return KErrNone if OK, other system error if failed
       
    96     	*/        
       
    97         TInt ConvertVersion(TLex8& aParser, TDpsVersion& aVersion);    
       
    98         
       
    99         /**
       
   100         *   @return CDpsStateMachine pointer to dps state machine object
       
   101         */
       
   102         inline CDpsStateMachine* Operator();
       
   103         
       
   104         /**
       
   105         *   Parses the string of percentage to integer
       
   106         *   @param aPer the string of percentage to be parsed
       
   107         *   @return TInt the percentage in integer
       
   108         */    			
       
   109         TInt ParsePercentage(const TDes8& aPer);
       
   110         
       
   111         /**
       
   112         *   @return the error of result in integer
       
   113         */
       
   114         inline TInt ResultErr();
       
   115                     
       
   116             
       
   117         /**
       
   118         *   @return CDpsFile pointer to dps file object
       
   119         */
       
   120         inline CDpsFile* FileHandle();
       
   121         
       
   122         /**
       
   123         *
       
   124         */
       
   125         void HandleHostRequestError(TInt aErr);
       
   126                     
       
   127     private:
       
   128         /**
       
   129         *   Default constructor
       
   130         *   
       
   131         *   @param iOperator the pointer to the dps operator 
       
   132         */	
       
   133     	CDpsTransaction(CDpsStateMachine* iOperator);    
       
   134     	
       
   135     	/**
       
   136     	*   Second phase constructor. 
       
   137     	*/
       
   138     	void ConstructL();
       
   139     	
       
   140     	/**
       
   141     	*   Creates the dps event reply.
       
   142     	*   @param aArguments dps event arguments
       
   143     	*   @param aResult the result of the reply. See Dps spec for
       
   144     	*   detail result value
       
   145     	*/
       
   146     	void CreateEventReplyL(TDpsEvent aEvent, const TDpsResult& aResult);
       
   147     	
       
   148     	/**
       
   149     	*   Creates the dps request reply based on host dps request.
       
   150     	*   There is only one dps request from host (others are from device) -
       
   151     	*   GetFileID
       
   152     	*   @param aArgs the dps argument from the dps xml script
       
   153     	*   @param aResult the reply result to be filling to the dps xml script
       
   154     	*/
       
   155     	void CreateRequestReplyL(const TDpsArgArray& aArgs, 
       
   156                                  const TDpsResult& result);
       
   157         
       
   158         /**
       
   159         *   Removes the unprintable chars (LF, CR, TAB and spaces) between 
       
   160         *   two XML attributes. It seems
       
   161         *   sybmian XML framework does filter out these character even though
       
   162         *   they are not belong to the attribute. Some printers (Cannon) send
       
   163         *   Dps request (XML script) in human readable format, e.g. including
       
   164         *   LF, CR and spaces among XML attributes.
       
   165         *   @param aScript the XML script to be filtered out
       
   166         */
       
   167     	void Filter(TDes8& aScript);
       
   168     	
       
   169     	/**
       
   170     	*   Changes the file path for GetFileID request
       
   171     	*
       
   172     	*/
       
   173     	void SubstitutePath(TDes8& aPath);
       
   174     	
       
   175     private:
       
   176         
       
   177     	// the pointer to dps operator object
       
   178     	// not owned by this class
       
   179         CDpsStateMachine* iOperator;
       
   180         // the pointer to xml generator object, owned by this class
       
   181         CDpsXmlGenerator *iXmlGen;
       
   182         // the pointer to xml parser object, owned by this class
       
   183         CDpsXmlParser *iXmlPar; 
       
   184         // the pointer to file generator object, owned by this class
       
   185         CDpsFile *iFile;
       
   186                 
       
   187         // the current parsed script is reply or request
       
   188         TBool iReply;  
       
   189     };
       
   190 
       
   191 #include "dpstransaction.inl"
       
   192 #endif