usbuis/imageprintui/src/capabilitymanager.cpp
changeset 0 1e05558e2206
child 55 c00b160ac7eb
equal deleted inserted replaced
-1:000000000000 0:1e05558e2206
       
     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:  Retrieve printing capabilites from printer 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "capabilitymanager.h"
       
    20 #include "imageprintuidebug.h"
       
    21 #include "imageprintuiappui.h"
       
    22 #include <dpsdefs.h>
       
    23 #include <dpsparam.h>
       
    24 #include <barsc.h>
       
    25 #include <barsread.h>
       
    26 #include <bautils.h>
       
    27 #include <f32file.h>
       
    28 #include <pathinfo.h> 
       
    29 #include <phonecapability.rsg>
       
    30 
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CCapabilityManager::NewL
       
    36 // Two-phased constructor.
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CCapabilityManager* CCapabilityManager::NewL(CImagePrintUiAppUi* aAppUi, CDpsEngine* aEngine)
       
    40     {
       
    41     FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager:NewL"));
       
    42     CCapabilityManager* self 
       
    43         = new (ELeave) CCapabilityManager(aAppUi, aEngine);
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     CleanupStack::Pop( self ); 
       
    47     return self;
       
    48     }
       
    49 
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CCapabilityManager::~CCapabilityManager
       
    53 // C++ default destructor
       
    54 // -----------------------------------------------------------------------------
       
    55 //    
       
    56 CCapabilityManager::~CCapabilityManager()
       
    57     {
       
    58     FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager: desctructor"));
       
    59     Cancel(); // cancels any existing active object orders for iStatus
       
    60     
       
    61     iReturnArray.Close();
       
    62     iCurrentLayouts.Close();
       
    63     iCurrentPaperSizes.Close();
       
    64     iCurrentQualities.Close();
       
    65        
       
    66     iPhoneSuppQuality.Close();
       
    67     iPhoneSuppPaperSize.Close();   
       
    68     iPhoneSuppLayout.Close();
       
    69     FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager: desctructor complete"));
       
    70     }
       
    71 
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CCapabilityManager::CCapabilityManager
       
    75 // C++ default constructor 
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CCapabilityManager::CCapabilityManager(CImagePrintUiAppUi* aAppUi, CDpsEngine* aEngine)
       
    79     : CActive(EPriorityStandard), 
       
    80     iAppUi(aAppUi), iDpsEngine(aEngine),
       
    81     iUserSelectedQuality(EDpsPrintQualityDefault),
       
    82     iUserSelectedPaperSize(EDpsPaperSizeDefault),
       
    83     iUserSelectedLayout(EDpsLayoutDefault)
       
    84     {
       
    85     CActiveScheduler::Add(this);
       
    86     }
       
    87 
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CCapabilityManager::RunError
       
    91 // Standard active object error function.
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 
       
    95 TInt CCapabilityManager::RunError(TInt aError)
       
    96     {
       
    97     FTRACE(FPrint(_L("[IMAGEPRINTUI]CCapabilityManager RunError is %d ."), aError));
       
    98     return KErrNone;
       
    99     }
       
   100 
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CCapabilityManager::RunL
       
   104 // This function will be called upon a change in the watched key.
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CCapabilityManager::RunL()
       
   108     {
       
   109     FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL"));
       
   110     if(iStatus.Int() == KErrNone && iLayoutForPaperSize)
       
   111     	{
       
   112     	FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL layout for papersize asked"));
       
   113     	HandleLayoutForPaperSize();
       
   114     	return;
       
   115     	}
       
   116     
       
   117     if ( iStatus.Int() == KErrNone )
       
   118     	{
       
   119     	FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL, no error in iStatus"));
       
   120         HandleCapabilitiesL(iCapabilityType); 
       
   121     	}
       
   122     
       
   123     else 
       
   124     	{
       
   125     	FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL, there is error in iStatus"));
       
   126     	FTRACE(FPrint(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL: ERROR is %d  ."), iStatus.Int()));
       
   127     	iAppUi->HandleCapabilityTime(KRetryAsk);
       
   128     	FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::Timer called"));
       
   129     	}
       
   130     FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::RunL complete."));
       
   131     }
       
   132 
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CCapabilityManager::ConstructL
       
   136 // Construct member variable iPersonalityRepository that is to access the
       
   137 // repository. Then start listening of the changes in the repository.
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CCapabilityManager::ConstructL()
       
   141     {
       
   142     FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager: ConstructL"));
       
   143     iCapabilityNotChanged = EFalse;
       
   144     iIsCapabilityEmpty = EFalse;
       
   145     iLayoutForPaperSize = EFalse;
       
   146     
       
   147     iPhoneSuppLayout = RArray<TUint>(KDefaultArray);  
       
   148     iPhoneSuppPaperSize = RArray<TUint>(KDefaultArray);
       
   149     iPhoneSuppQuality = RArray<TUint>(KDefaultArray);  
       
   150     iCurrentQualities = RArray<TUint>(KDefaultArray);
       
   151     iCurrentPaperSizes = RArray<TUint>(KDefaultArray);
       
   152     iCurrentLayouts = RArray<TUint>(KDefaultArray);
       
   153     
       
   154     iReturnArray = RArray<TUint>(KDefaultArray);
       
   155     
       
   156     GetPhoneConfigL();
       
   157     FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager: ConstructL complete"));        
       
   158     }
       
   159 
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // 
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CCapabilityManager::AskCapabilitiesL(TBool aChanged)
       
   166 	{
       
   167 	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager::AskCapabilitiesL iStatus   is %d"), iStatus.Int() ));  
       
   168     
       
   169 	if(aChanged)
       
   170 		{
       
   171 		if(iStatus.Int() == KErrNotReady) // this is collision situation, have asked earlier and event capability
       
   172 			{                             // change requires asking again when AO is already active
       
   173 		    FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskCapabilitiesL not ready when capability change")); 
       
   174 		    return;	
       
   175 			}
       
   176 		else
       
   177 			{
       
   178 		    FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskCapabilities cancel pending"));
       
   179 			Cancel();
       
   180 			}
       
   181 		
       
   182 		}
       
   183 	if(!IsActive())
       
   184 		{
       
   185 		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::start ask paper size "));
       
   186 	    AskPaperSizeL();	
       
   187 		}
       
   188 	else
       
   189 		{
       
   190 		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::cannot ask quality, already active "));
       
   191 		}
       
   192 	
       
   193 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskCapabilities"));
       
   194     
       
   195 	}
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // 
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 void CCapabilityManager::AskQualityL()
       
   202 	{
       
   203 	iCap.iRepParam.Reset();
       
   204 	FLOG(_L("[IMAGEPRINTUI]>>> CCapabilityManager::AskQualityL "));
       
   205 	iCap.iReqParam.iCap = EDpsArgQualities;
       
   206     iCapabilityType = EQualities;
       
   207     iDpsEngine->DoDpsRequestL(&iCap, iStatus);	
       
   208 	SetActive();
       
   209 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskQualityL "));
       
   210 	}
       
   211 
       
   212 // ---------------------------------------------------------------------------
       
   213 // 
       
   214 // ---------------------------------------------------------------------------
       
   215 //	
       
   216 void CCapabilityManager::AskPaperSizeL()
       
   217 	{
       
   218 	iCap.iRepParam.Reset();
       
   219 	FLOG(_L("[IMAGEPRINTUI]>>> CCapabilityManager::AskPaperSizeL "));
       
   220 	iCap.iReqParam.iCap = EDpsArgPaperSizes;
       
   221     iCapabilityType = EPaperSize;
       
   222     iDpsEngine->DoDpsRequestL(&iCap, iStatus);	
       
   223 	SetActive();
       
   224 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskPaperSizeL "));
       
   225 	}	
       
   226 
       
   227 // ---------------------------------------------------------------------------
       
   228 // 
       
   229 // ---------------------------------------------------------------------------
       
   230 //	
       
   231 void CCapabilityManager::AskLayoutL()
       
   232 	{
       
   233 	iCap.iRepParam.Reset();
       
   234 	FLOG(_L("[IMAGEPRINTUI]>>> CCapabilityManager::AskLayoutL "));
       
   235     
       
   236     iCap.iReqParam.iCap = EDpsArgLayouts;
       
   237     iCap.iReqParam.iAttribute = EDpsPaperSizeDefault;
       
   238     iCapabilityType = ELayouts;
       
   239     iDpsEngine->DoDpsRequestL(&iCap, iStatus);	
       
   240 	SetActive();
       
   241 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskLayoutL "));
       
   242 	}	
       
   243 
       
   244 // ---------------------------------------------------------------------------
       
   245 // 
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 void CCapabilityManager::AskLayoutForPaperSizeL(TUint aPaperSize)
       
   249 	{
       
   250 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::AskLayoutForPaperSizeL "));
       
   251 	iCap.iRepParam.Reset();
       
   252 	iCap.iReqParam.iCap = EDpsArgLayouts;
       
   253     iCap.iReqParam.iAttribute = aPaperSize;
       
   254    	iDpsEngine->DoDpsRequestL(&iCap, iStatus);
       
   255    	
       
   256 	if(!IsActive())
       
   257 		{
       
   258 		iLayoutForPaperSize = ETrue;
       
   259 	    SetActive(); 	
       
   260 		}
       
   261 	}
       
   262 
       
   263 
       
   264 // -----------------------------------------------------------------------------
       
   265 // CCapabilityManager::DoCancel
       
   266 // Standard active object cancellation function.
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void CCapabilityManager::DoCancel()
       
   270     {
       
   271     FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::DoCancel"));
       
   272     iDpsEngine->CancelDpsRequest();
       
   273     FLOG(_L("[IMAGEPRINTUI]\tCCapabilityManager::DoCancel complete"));
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 //  
       
   278 // ---------------------------------------------------------------------------
       
   279 //	
       
   280 RArray<TUint>& CCapabilityManager::GetCapabilities(TInt aCapabilities)
       
   281     {
       
   282     FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager.GetCapabilities"));
       
   283     iReturnArray.Reset();
       
   284     
       
   285     switch ( aCapabilities )
       
   286 	    {        
       
   287 	    case EDpsArgQualities:
       
   288 	    	for(int i = 0; i < iCurrentQualities.Count(); i++ )
       
   289 	    		{
       
   290 	    		iReturnArray.Append(iCurrentQualities.operator[](i));
       
   291 	    		}
       
   292 	        break;
       
   293 	  
       
   294 	    case EDpsArgPaperSizes:
       
   295 	        for(int i = 0; i < iCurrentPaperSizes.Count(); i++ )
       
   296 	    		{
       
   297 	    		iReturnArray.Append(iCurrentPaperSizes.operator[](i));
       
   298 	    		}	
       
   299 	        break;
       
   300 	        
       
   301 	    case EDpsArgLayouts:
       
   302 	    	for(int i = 0; i < iCurrentLayouts.Count(); i++ )
       
   303 	    		{
       
   304 	    		iReturnArray.Append(iCurrentLayouts.operator[](i));
       
   305 	    		}
       
   306 			break;		
       
   307 	    default:
       
   308 	        FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager.GetCapabilities default brach"));
       
   309 	        break;  
       
   310 	    }     
       
   311     FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager.GetCapabilities")); 
       
   312     return iReturnArray;
       
   313     }  
       
   314 
       
   315 // ---------------------------------------------------------------------------
       
   316 // User has choosed value for saving
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 void CCapabilityManager::SetValue(TInt aCapability, TUint aValue)
       
   320     { 
       
   321     FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager.SetValue"));
       
   322     switch ( aCapability )
       
   323 	    {        
       
   324 	    case EDpsArgQualities:
       
   325 	        FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager::SetValue in quality is %x"), aValue ));
       
   326 	        iUserSelectedQuality = aValue;	
       
   327 	        break;
       
   328 	            
       
   329 	    case EDpsArgPaperSizes:
       
   330 	        FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager::SetValue in papersize is %x"), aValue ));
       
   331 	        iUserSelectedPaperSize = aValue;
       
   332 	        // now user has select papersize, retrive layout for certain papersize
       
   333 	        TRAPD(err,AskLayoutForPaperSizeL(aValue));
       
   334 	        if(err)
       
   335 	        	{
       
   336 	        	FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager.AskLayoutForPaperSizeL was unsuccessfull"));
       
   337 	        	}
       
   338 	        break;
       
   339 	            
       
   340 	    case EDpsArgLayouts:
       
   341 	    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager::SetValue in layouts is %x"), aValue ));
       
   342 	        iUserSelectedLayout = aValue; 	
       
   343 	        break;
       
   344 	    default:
       
   345 	     	break;  
       
   346 	    } 		
       
   347 	FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager.SetValue"));    
       
   348     }     
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 //  UI requires current value
       
   352 // ---------------------------------------------------------------------------
       
   353 //	
       
   354 TUint CCapabilityManager::CurrentPrintSettings(TInt aDpsArg)
       
   355 	{
       
   356 	FLOG(_L("[IMAGEPRINTUI]<<<CCapabilityManager::CurrentPrintSettings"));
       
   357 	TUint retValue;
       
   358 	if(aDpsArg == EDpsArgQualities)
       
   359 		{
       
   360         retValue = iUserSelectedQuality;		
       
   361 		}
       
   362     else if(aDpsArg == EDpsArgPaperSizes)
       
   363     	{
       
   364     	retValue = iUserSelectedPaperSize;
       
   365     	}
       
   366     else if(aDpsArg == EDpsArgLayouts)
       
   367     	{
       
   368     	retValue = iUserSelectedLayout;
       
   369     	}
       
   370     else if(aDpsArg != EDpsArgQualities &&  
       
   371             aDpsArg != EDpsArgPaperSizes && aDpsArg != EDpsArgLayouts)
       
   372     	{
       
   373     	FLOG(_L("[IMAGEPRINTUI]\t CCapabilityManager: Wrong value asked"));
       
   374     	retValue = (TUint)KErrArgument;
       
   375     	}
       
   376     FLOG(_L("[IMAGEPRINTUI]>>>CCapabilityManager CurrentPrintSettings"));
       
   377     return retValue;		
       
   378 	}   
       
   379 	
       
   380 // ---------------------------------------------------------------------------
       
   381 // Gives paper size value for DoDpsRequest
       
   382 // ---------------------------------------------------------------------------
       
   383 //	
       
   384 TUint CCapabilityManager::PaperSize()
       
   385 	{
       
   386 	return iUserSelectedPaperSize;
       
   387 	}   
       
   388 	
       
   389 // ---------------------------------------------------------------------------
       
   390 // Gives layout value for DoDpsRequest
       
   391 // ---------------------------------------------------------------------------
       
   392 //
       
   393 TUint CCapabilityManager::Layout()
       
   394 	{
       
   395 	return iUserSelectedLayout;
       
   396 	}   
       
   397 	
       
   398 // ---------------------------------------------------------------------------
       
   399 // Gives quality value for DoDpsRequest
       
   400 // ---------------------------------------------------------------------------
       
   401 //
       
   402 TUint CCapabilityManager::Quality()
       
   403 	{
       
   404 	return iUserSelectedQuality;
       
   405 	}   
       
   406 	
       
   407 // ---------------------------------------------------------------------------
       
   408 //  Goes through phone supported quality values and compare with printer supported,
       
   409 //  if both supported save value 
       
   410 // ---------------------------------------------------------------------------
       
   411 
       
   412 void CCapabilityManager::StoreQualitiesL(RArray<TUint>& aPrinterQualities)
       
   413 	{
       
   414 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Store qualities"));
       
   415 	TInt countPrinter, countPhone;
       
   416 	TUint compareValue;
       
   417 	countPrinter = aPrinterQualities.Count();
       
   418 	countPhone = iPhoneSuppQuality.Count();
       
   419 	iIsCapabilityEmpty = EFalse;
       
   420 	iCurrentQualities.Reset();
       
   421 	
       
   422 	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager aPrinterQualities count is %d"), aPrinterQualities.Count() ));
       
   423 	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager iPhoneSuppQuality count is %d"), iPhoneSuppQuality.Count() ));
       
   424   
       
   425 	
       
   426 	for(int r=0; r < countPrinter; r++)
       
   427 		{
       
   428 		compareValue = aPrinterQualities[r];
       
   429 		for(int d=0; d < countPhone; d++)
       
   430 			{
       
   431 		    if(compareValue == iPhoneSuppQuality[d])
       
   432 		    	{
       
   433 		    	iIsCapabilityEmpty = ETrue;
       
   434 		    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager compareValue save quality is %x"), compareValue ));
       
   435 		    	iCurrentQualities.Append(compareValue);
       
   436 		    	}
       
   437 			}
       
   438 		}
       
   439 	if(!iIsCapabilityEmpty)	
       
   440 		{
       
   441 		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: qualities add default value"));
       
   442 		iCurrentQualities.Append(EDpsPrintQualityDefault);
       
   443 		}
       
   444 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: qualities stored, ask layout"));	
       
   445     iCurrentQualities.Sort();
       
   446 	AskLayoutL();	
       
   447 	}
       
   448 	
       
   449 		
       
   450 // ---------------------------------------------------------------------------
       
   451 //  Goes through phone supported paper size values and compare with printer supported,
       
   452 //  if both supported save value 
       
   453 // ---------------------------------------------------------------------------
       
   454 void CCapabilityManager::StorePaperSizeL(RArray<TUint>& aPrinterPaperSize)
       
   455     {
       
   456     FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Store paper size"));
       
   457     TInt countPrinter, countPhone;
       
   458     TUint compareValue;
       
   459 	countPrinter = aPrinterPaperSize.Count();
       
   460 	countPhone = iPhoneSuppPaperSize.Count();
       
   461 	iIsCapabilityEmpty = EFalse;
       
   462 	iCurrentPaperSizes.Reset();
       
   463 	
       
   464 	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager aPrinterPaperSize count is %d"), aPrinterPaperSize.Count() ));
       
   465 	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager iPhoneSuppPaperSize count is %d"), iPhoneSuppPaperSize.Count() ));
       
   466   
       
   467 	
       
   468 	for(int r=0; r < countPrinter; r++)
       
   469 		{
       
   470 		compareValue = aPrinterPaperSize[r];
       
   471 		for(int f=0; f < countPhone; f++)
       
   472 			{
       
   473 		    if(compareValue == iPhoneSuppPaperSize[f])
       
   474 		    	{
       
   475 		    	iIsCapabilityEmpty = ETrue;
       
   476 		    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager compareValue save paper size is %x"), compareValue ));
       
   477 		    	iCurrentPaperSizes.Append(compareValue);
       
   478 		    	}
       
   479 			}	
       
   480 		}
       
   481 	if(!iIsCapabilityEmpty)	
       
   482 		{
       
   483 		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: paper size add default value"));
       
   484 		iCurrentPaperSizes.Append(EDpsPaperSizeDefault);
       
   485 		}
       
   486 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: paper sizes stored, ask quality"));
       
   487 	iCurrentPaperSizes.Sort();
       
   488 	AskQualityL();	
       
   489     }
       
   490       
       
   491 // ---------------------------------------------------------------------------
       
   492 //  Goes through phone supported layout values and compare with printer supported,
       
   493 //  if both supported save value 
       
   494 // ---------------------------------------------------------------------------
       
   495 void CCapabilityManager::StoreLayouts(RArray<TUint>& aPrinterLayouts)
       
   496 	{
       
   497 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Store layouts"));
       
   498 	TInt countPrinter, countPhone;
       
   499 	TUint compareValue;
       
   500 	countPrinter = aPrinterLayouts.Count();
       
   501 	countPhone = iPhoneSuppLayout.Count();	
       
   502 	iIsCapabilityEmpty = EFalse;
       
   503 	iCurrentLayouts.Reset();
       
   504 	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager aPrinterLayouts count is %d"), aPrinterLayouts.Count() ));
       
   505 	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager iPhoneSuppLayout count is %d"), iPhoneSuppLayout.Count() ));
       
   506   
       
   507 	for(int r=0; r < countPrinter; r++)
       
   508 		{
       
   509 		compareValue = aPrinterLayouts[r];
       
   510 		for(int e=0; e < countPhone; e++)
       
   511 			{
       
   512 		    if(compareValue == iPhoneSuppLayout[e])
       
   513 		    	{
       
   514 		    	iIsCapabilityEmpty = ETrue;
       
   515 		    	FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager compareValue save layout is %x"), compareValue ));
       
   516 		    	iCurrentLayouts.Append(compareValue);
       
   517 		    	}
       
   518 			}	
       
   519 		}
       
   520 		
       
   521 	if(!iIsCapabilityEmpty)	
       
   522 		{
       
   523 		FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: layout add default value"));
       
   524 		iCurrentLayouts.Append(EDpsLayoutDefault);
       
   525 		}
       
   526 	
       
   527 	iCurrentLayouts.Sort();	
       
   528 	if(iCapabilityAskFailed)
       
   529 		{
       
   530         // all capabilities has asked
       
   531         // asking one of the tree capabilities was unsuccessfull
       
   532 	    FLOG(_L("[IMAGEPRINTUI]<<< :CCapabilityManager, Capabilities NOT ready "));	
       
   533 	    iAppUi->CapabilitiesReady(); 
       
   534 	 	}
       
   535 	else
       
   536 		{
       
   537 		FLOG(_L("[IMAGEPRINTUI]<<< :CCapabilityManager, Capabilities are ready "));
       
   538 		iAppUi->CapabilitiesReady(); 
       
   539 		}		
       
   540 	}
       
   541 
       
   542 
       
   543 // ---------------------------------------------------------------------------
       
   544 // 
       
   545 // ---------------------------------------------------------------------------
       
   546 //
       
   547 void CCapabilityManager::HandleLayoutForPaperSize()
       
   548 	{
       
   549 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager::HandleLayoutForPaperSize"));
       
   550 	StoreLayouts(iCap.iRepParam.iContent); 
       
   551 	}
       
   552 // ---------------------------------------------------------------------------
       
   553 // 
       
   554 // ---------------------------------------------------------------------------
       
   555 //
       
   556 void CCapabilityManager::HandleCapabilitiesL(TCapabilityType aType)
       
   557 	{
       
   558 		
       
   559 	if(aType == EQualities)
       
   560 		{
       
   561 		if(iCap.iResult.iMajorCode == EDpsResultOk)
       
   562 			{					
       
   563 			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request qualities capability OK"));
       
   564 			FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL qualities amount is %d"), iCap.iRepParam.iContent.Count() ));	
       
   565 			for(int r=0; r < iCap.iRepParam.iContent.Count(); r++)
       
   566 				{
       
   567 				FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL qualities is %x"), iCap.iRepParam.iContent[r] ));	
       
   568 				}
       
   569 	        StoreQualitiesL(iCap.iRepParam.iContent);
       
   570 			}
       
   571 		else
       
   572 			{
       
   573 			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request qualities capability NOK"));
       
   574 			iCapabilityAskFailed = ETrue;
       
   575 			// if fails add default value
       
   576 			iAppUi->NotifyError();
       
   577 			iCurrentQualities.Reset();
       
   578 			iCurrentQualities.Append(EDpsPrintQualityDefault);
       
   579 			AskLayoutL();
       
   580 			}
       
   581 		
       
   582 		}
       
   583  	else if(aType == EPaperSize)
       
   584  		{
       
   585  		if(iCap.iResult.iMajorCode == EDpsResultOk)
       
   586  			{
       
   587  		    FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request paper size capability OK"));
       
   588  		    FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL papersize amount is %d"), iCap.iRepParam.iContent.Count() ));
       
   589 			for(int r=0; r < iCap.iRepParam.iContent.Count(); r++)
       
   590 				{
       
   591 				FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL paper size is %x"), iCap.iRepParam.iContent[r] ));
       
   592 				}
       
   593 	        
       
   594  		    StorePaperSizeL(iCap.iRepParam.iContent);
       
   595  			}
       
   596  		else
       
   597  			{
       
   598  			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request paper size capability NOK"));
       
   599  			iCapabilityAskFailed = ETrue;
       
   600  			// if fails add default value;
       
   601  			iAppUi->NotifyError();
       
   602  			iCurrentPaperSizes.Reset();
       
   603  			iCurrentPaperSizes.Append(EDpsPaperSizeDefault);
       
   604  			AskQualityL();
       
   605  			}
       
   606  		
       
   607  		}
       
   608  	else if(aType == ELayouts)
       
   609  		{
       
   610  		if(iCap.iResult.iMajorCode == EDpsResultOk)
       
   611  			{
       
   612  			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request layout capability OK"));
       
   613  			FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL layout amount is %d"), iCap.iRepParam.iContent.Count() ));	
       
   614 			for(int r=0; r < iCap.iRepParam.iContent.Count(); r++)
       
   615 				{
       
   616 				FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CCapabilityManager HandleCapabilitiesL layout is %x"), iCap.iRepParam.iContent[r] ));	
       
   617 				}
       
   618  		    StoreLayouts(iCap.iRepParam.iContent); 	
       
   619  			}
       
   620  		else
       
   621  			{
       
   622  			FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager: Dps request layout capability NOK"));
       
   623  			iCapabilityAskFailed = ETrue;
       
   624  			//if fails add default value
       
   625  			iAppUi->NotifyError();
       
   626  			iCurrentLayouts.Reset();
       
   627  			iCurrentLayouts.Append(EDpsLayoutDefault);
       
   628  			// complete even if not succesfull, UI must activate
       
   629  			iAppUi->CapabilitiesReady();
       
   630  			}
       
   631  		
       
   632  		}
       
   633     
       
   634 	}
       
   635 
       
   636 // ---------------------------------------------------------------------------
       
   637 // 
       
   638 // ---------------------------------------------------------------------------
       
   639 //
       
   640 void CCapabilityManager::GetPhoneConfigL()
       
   641     {
       
   642     FLOG(_L("[IMAGEPRINTUI]>>> :CCapabilityManager, GetPhoneConfigL BEGIN"));
       
   643     
       
   644         
       
   645     TBuf<KResource> resourceFile(PathInfo::RomRootPath());
       
   646     TBuf<KResource> length(KPhoneCapability);    
       
   647     resourceFile.SetLength(KDriver + length.Length());
       
   648     resourceFile.Replace(KDriver, length.Length(), KPhoneCapability);
       
   649     
       
   650     RResourceFile resource;
       
   651     resource.OpenL(CCoeEnv::Static()->FsSession(),  resourceFile);
       
   652     FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, Resource open"));
       
   653     
       
   654     CleanupClosePushL(resource);
       
   655     resource.ConfirmSignatureL(KPhoneCapabilityVersion);
       
   656     
       
   657     HBufC8* id = resource.AllocReadLC(PHONECAPABILITY_CONFIG);
       
   658     
       
   659     TResourceReader reader;
       
   660     reader.SetBuffer(id);   
       
   661     
       
   662     TInt qualityCount = reader.ReadUint8();
       
   663     TInt papersizeCount = reader.ReadUint8();
       
   664     TInt layoutCount  = reader.ReadUint8();
       
   665       
       
   666        
       
   667     for (TInt i = 0; i < qualityCount; i++)
       
   668     	{
       
   669     	iPhoneSuppQuality.Append(reader.ReadUint16());
       
   670     	}
       
   671     FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, quality readed"));
       
   672     	
       
   673     for (TInt i = 0; i < papersizeCount; i++)
       
   674     	{
       
   675        	iPhoneSuppPaperSize.Append(reader.ReadUint16());
       
   676     	}		
       
   677     
       
   678     FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, papersize readed"));
       
   679     for (TInt i = 0; i < layoutCount; i++)
       
   680     	{
       
   681     	iPhoneSuppLayout.Append(reader.ReadUint16());
       
   682     	}
       
   683     FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, layout readed"));
       
   684     	
       
   685     CleanupStack::PopAndDestroy(id);
       
   686     CleanupStack::PopAndDestroy(&resource);
       
   687     FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:CCapabilityManager GetPhoneConfigL END "));
       
   688     }
       
   689    
       
   690 // ---------------------------------------------------------------------------
       
   691 // 
       
   692 // ---------------------------------------------------------------------------
       
   693 //
       
   694 void CCapabilityManager::CheckIfNewCapabilityDiffer()
       
   695 	{
       
   696 	FLOG(_L("[IMAGEPRINTUI]>>> CCapabilityManager:: CheckIfNewCapabilityDiffer"));
       
   697 	TBool compareValue = EFalse;
       
   698 	
       
   699 	
       
   700 	for(TInt i = 0; i  < iCurrentLayouts.Count(); i++)
       
   701 		{
       
   702 		if(iCurrentLayouts.operator[](i) == iUserSelectedLayout )
       
   703 			{
       
   704 			compareValue = ETrue;
       
   705 			}
       
   706 		
       
   707 		}
       
   708 		
       
   709 	if(!compareValue)
       
   710 		{
       
   711 		FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:: user selected layout not supported"));
       
   712 		iUserSelectedLayout = EDpsLayoutDefault;
       
   713 		}
       
   714 		
       
   715     compareValue = EFalse;		
       
   716 	
       
   717 	for(TInt i = 0; i  < iCurrentQualities.Count(); i++)
       
   718 		{
       
   719 		if(iCurrentQualities.operator[](i) == iUserSelectedQuality )
       
   720 			{
       
   721 			compareValue = ETrue;
       
   722 			}
       
   723 			 
       
   724 		}
       
   725 		
       
   726 	if(!compareValue)
       
   727 		{
       
   728 		FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:: user selected quality not supported"));
       
   729 		iUserSelectedQuality = EDpsPrintQualityDefault;
       
   730 		}
       
   731     	
       
   732 	compareValue = EFalse;
       
   733 
       
   734     for(TInt i = 0; i  < iCurrentPaperSizes.Count(); i++)
       
   735 		{
       
   736 		if(iCurrentPaperSizes.operator[](i) == iUserSelectedPaperSize )
       
   737 			{
       
   738 			compareValue = ETrue;
       
   739 			}
       
   740 		} 
       
   741 
       
   742 	if(!compareValue)
       
   743 		{
       
   744 		FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:: user selected paper size not supported"));
       
   745 		iUserSelectedPaperSize = EDpsPaperSizeDefault;
       
   746 		}
       
   747 	FLOG(_L("[IMAGEPRINTUI]<<< CCapabilityManager:: CheckIfNewCapabilityDiffer"));	
       
   748 	}
       
   749 
       
   750 // End of file