usbuis/imageprintui/inc/capabilitymanager.h
changeset 93 2dc695882abd
parent 89 3592750162a5
equal deleted inserted replaced
89:3592750162a5 93:2dc695882abd
     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:  Header file for capabilitymanager
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CAPABILITYMANAGER_H
       
    20 #define CAPABILITYMANAGER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <pictbridge.h>
       
    24 #include <dpsoperation.h>
       
    25 #include <dpsparam.h>
       
    26 #include <badesca.h>
       
    27 
       
    28 
       
    29 const TInt KPhoneCapabilityVersion = 0;
       
    30 const TInt KRetryAsk = 2 * 100 * 1000; // 200 ms
       
    31 const TInt KDefaultArray = 5;
       
    32 _LIT(KPhoneCapability, "private\\1020e470\\phonecapability.rsc");
       
    33 
       
    34 class CImagePrintUiAppUi;
       
    35 
       
    36 /**
       
    37 * CCapabilityManager is an active object that sends an asynchronous request 
       
    38 * to retrieve capabilities
       
    39 */
       
    40 class CCapabilityManager : public CActive
       
    41     {
       
    42         
       
    43 public:
       
    44 
       
    45     /**
       
    46     * Factory method NewL
       
    47     * @param aOwner  The observer to be notified on the change. 
       
    48     * @param aEngine the pointer to the PictBridge engine
       
    49     * @return instance of capability manager        
       
    50     */
       
    51     static CCapabilityManager* NewL(CImagePrintUiAppUi* aAppUi, CDpsEngine* aEngine);
       
    52 
       
    53 
       
    54     /**
       
    55     * Destructor.
       
    56     */
       
    57     virtual ~CCapabilityManager();
       
    58         
       
    59        
       
    60     /**
       
    61      * Gives current qualities for doDpsRequest 
       
    62      * 
       
    63      */   
       
    64      TUint Quality();
       
    65 
       
    66 	
       
    67 	/**
       
    68      * Gives current paper size for doDpsRequest
       
    69      * 
       
    70      */  
       
    71      TUint PaperSize();
       
    72 	
       
    73 	/**
       
    74      * Gives current  paper layout for doDpsRequest
       
    75      * 
       
    76      */  
       
    77      TUint Layout();
       
    78     
       
    79 	/**
       
    80      * Gives current print setting to UI
       
    81      * 
       
    82      */  
       
    83 	 TUint CurrentPrintSettings(TInt aDpsArg);
       
    84 	
       
    85 	/**
       
    86      * All qualities asked by UI engine
       
    87      * @param aReason the answer for request complete to UI capability query 
       
    88      */  
       
    89 	void QualitiesAsked(TInt aReason);
       
    90 
       
    91 
       
    92     /**
       
    93      * Return certain type list of Capabilities
       
    94      * @param aCapability the Capabilities type requested
       
    95      */
       
    96     RArray<TUint>& GetCapabilitiesL(TInt aCapability);
       
    97     
       
    98     /**
       
    99     * Stores value choosed by user
       
   100     */
       
   101     void SetValue(TInt aCapability, TUint aValue);
       
   102     
       
   103     /**
       
   104     * Ask capabilities when needed
       
   105     *
       
   106     */
       
   107     void AskCapabilitiesL(TBool aChanged);
       
   108     
       
   109     
       
   110      /**
       
   111     * Ask layout when user has selected certain papersize
       
   112     *
       
   113     */
       
   114     void AskLayoutForPaperSizeL(TUint aPaperSize);
       
   115     
       
   116     
       
   117     
       
   118     /**
       
   119     * Check if capabilities differ when user start print
       
   120     *
       
   121     */ 
       
   122     void CheckIfNewCapabilityDiffer();
       
   123    
       
   124 
       
   125 private: //from CActive
       
   126     /**
       
   127     *	Implements CActive
       
   128     *   If this is not a one-shot CR watcher, the listening is restarted.
       
   129     *	@param none
       
   130     *	@return none
       
   131     */
       
   132     void RunL();
       
   133     
       
   134     /**
       
   135     *	Implements CActive
       
   136     *	@param aError the error returned
       
   137     *	@return error
       
   138     */
       
   139     TInt RunError(TInt aError);
       
   140 
       
   141     /**
       
   142     *	Implements CActive
       
   143     *	@param none
       
   144     *	@return none
       
   145     */
       
   146     void DoCancel();
       
   147     
       
   148     
       
   149     /**
       
   150      * Stores current qualities 
       
   151      * 
       
   152      */   
       
   153     void StoreQualitiesL(RArray<TUint>& aCurrQualities);
       
   154     
       
   155     /**
       
   156      * Stores current paper size 
       
   157      * 
       
   158      */   
       
   159     void StorePaperSizeL(RArray<TUint>& aSuppPaperSize);
       
   160     
       
   161     /**
       
   162      * Stores current first paper layout 
       
   163      * 
       
   164      */    	
       
   165      void StoreLayouts(RArray<TUint>& aSuppLayouts);
       
   166     
       
   167     /**
       
   168      * Ask quality from printer
       
   169      */  
       
   170     void AskQualityL();
       
   171     
       
   172     /**
       
   173      * Ask paper size from printer 
       
   174      */  
       
   175     void AskPaperSizeL();
       
   176     
       
   177     /**
       
   178      *  Ask layout from printer
       
   179      */  
       
   180     void AskLayoutL();
       
   181     
       
   182 
       
   183 private: //own methods
       
   184 
       
   185     enum TCapabilityType
       
   186     	{
       
   187 		EQualities,
       
   188 		EPaperSize,
       
   189 		ELayouts
       
   190   		};    
       
   191 
       
   192    /**
       
   193     *   Second phase constructor. Operations which might leave should 
       
   194     *   be called here
       
   195     */ 
       
   196     void ConstructL();
       
   197 
       
   198        
       
   199     /**
       
   200     * Handles capabilities after RunL
       
   201     *
       
   202     */
       
   203     void HandleCapabilitiesL(TCapabilityType aType);
       
   204     
       
   205     /**
       
   206     * Read phone supported capabilities
       
   207     *
       
   208     */
       
   209     void GetPhoneConfigL();
       
   210 
       
   211     /**
       
   212     * C++ default constructor
       
   213     * @param aAppUi the pointer to the AppUi instance 
       
   214     * @param aEngine the pointer to the PictBridge engine
       
   215     */
       
   216     CCapabilityManager( CImagePrintUiAppUi* aAppUi, 
       
   217                         CDpsEngine* aEngine);
       
   218     
       
   219     
       
   220     
       
   221     /**
       
   222     * Handles result of asking layout for certain papersize
       
   223     *
       
   224     */ 
       
   225     void HandleLayoutForPaperSize();
       
   226       
       
   227      
       
   228 private: //data
       
   229     
       
   230     CImagePrintUiAppUi* iAppUi;
       
   231     
       
   232     /**
       
   233      * Instance to PictBridge Engine to get capabilities
       
   234      * Not own
       
   235      */
       
   236     CDpsEngine* iDpsEngine; 
       
   237     
       
   238     TBool iCapabilityAskFailed;
       
   239     TBool iCapabilityNotChanged;
       
   240     TBool iIsCapabilityEmpty;
       
   241     TBool iLayoutForPaperSize;
       
   242     
       
   243     TCapabilityType iCapabilityType;
       
   244     
       
   245     // types for DoDpsRequest
       
   246     TDpsGetCapability      iCap;
       
   247         
       
   248     
       
   249     //Arrays for storing and maintaining capabilities data after 
       
   250     //comparing printer and phone supported capabilities
       
   251     RArray<TUint> iCurrentQualities; 
       
   252     RArray<TUint> iCurrentPaperSizes;
       
   253     RArray<TUint> iCurrentLayouts;
       
   254     
       
   255         
       
   256     TUint iCurrentQuality;
       
   257     TUint iCurrentPaperSize;
       
   258     TUint iCurrentLayout;
       
   259     
       
   260     TUint iUserSelectedQuality;
       
   261     TUint iUserSelectedPaperSize;
       
   262     TUint iUserSelectedLayout;
       
   263     
       
   264     //phone supported capabilities
       
   265     RArray<TUint>  iPhoneSuppLayout;   
       
   266     RArray<TUint>  iPhoneSuppPaperSize;   
       
   267     RArray<TUint>  iPhoneSuppQuality;  
       
   268     
       
   269     RArray<TUint> iReturnArray;  
       
   270      
       
   271     };
       
   272 
       
   273 
       
   274 #endif      // CAPABILITYMANAGER_H
       
   275 
       
   276 // End of File