ImagePrint/ImagePrintEngine/DeviceProtocols/upnpprotocolfw2/src/cupnpprintingdevice.cpp
branchRCL_3
changeset 27 159fc2f68139
parent 21 26673e532f65
child 28 d59c248c9d36
equal deleted inserted replaced
21:26673e532f65 27:159fc2f68139
     1 /*
       
     2 * Copyright (c) 2002-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:  Declares CUPnPPrintingDevice class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <upnpsettings.h>
       
    20 #include <fbs.h>
       
    21 #include <upnpitem.h>
       
    22 #include <upnphttpmessage.h>
       
    23 #include <upnphttpmessagefactory.h>
       
    24 #include <upnpicons.mbg>
       
    25 
       
    26 #include "cupnpprintingdevice.h"
       
    27 #include "cuplogger.h"
       
    28 #include "upconsts.h"
       
    29 
       
    30 _LIT( KIconsFileName, "imageprintdata\\protocols\\upnpicons.mbm" );
       
    31 
       
    32 //--------------------------------------------------------------------------------------------
       
    33 //
       
    34 // CUPnPPrintingDevice::NewL
       
    35 //
       
    36 //--------------------------------------------------------------------------------------------
       
    37 MProtPrintingDevice* CUPnPPrintingDevice::NewL()
       
    38 	{
       
    39 		LOG("[CUPnPPrintingDevice]\t ConstructL");
       
    40 		return new (ELeave) CUPnPPrintingDevice();
       
    41 	}
       
    42 
       
    43 //--------------------------------------------------------------------------------------------
       
    44 //
       
    45 // CUPnPPrintingDevice::ConstructL
       
    46 //
       
    47 //--------------------------------------------------------------------------------------------
       
    48 void CUPnPPrintingDevice::ConstructL(const TDesC& /*aDLLPath*/)
       
    49 	{
       
    50 		LOG("[CUPnPPrintingDevice]\t ConstructL");
       
    51 
       
    52 		iPrinterContainer 	= CUPPrinterContainer::NewL();
       
    53 		iPrinterTimer 		= CPeriodic::NewL(CActive::EPriorityStandard);
       
    54 		iPrintFactory 	= CUPPrintFactory::NewL();
       
    55 
       
    56 		LOG("[CUPnPPrintingDevice]\t Done.");
       
    57 	}
       
    58 
       
    59 //--------------------------------------------------------------------------------------------
       
    60 //
       
    61 // CUPnPPrintingDevice::~CUPnPPrintingDevice
       
    62 //
       
    63 //--------------------------------------------------------------------------------------------
       
    64 CUPnPPrintingDevice::~CUPnPPrintingDevice()
       
    65 	{
       
    66 	  if (iPrinterTimer){
       
    67       iPrinterTimer->Cancel();
       
    68       delete iPrinterTimer;
       
    69     }
       
    70 
       
    71 		if (iPrinterControl)
       
    72 			delete iPrinterControl;
       
    73 
       
    74 		if (iFbsBitmap)
       
    75 			delete iFbsBitmap;
       
    76 
       
    77 		if (iPrintingJob)
       
    78 			delete iPrintingJob;
       
    79     
       
    80     if (iPrinterContainer)
       
    81 		  delete iPrinterContainer;
       
    82   
       
    83     if (iPrintFactory)
       
    84       delete iPrintFactory;
       
    85 
       
    86     REComSession::DestroyedImplementation( iDtor_ID_Key );
       
    87 	}
       
    88 
       
    89 //--------------------------------------------------------------------------------------------
       
    90 //
       
    91 // CUPnPPrintingDevice::DiscoveryTimeoutCBL
       
    92 //
       
    93 //--------------------------------------------------------------------------------------------
       
    94 TBool CUPnPPrintingDevice::DiscoveryTimeoutCBL(TAny *aWho)
       
    95 	{
       
    96 		CUPnPPrintingDevice *cbTarget = static_cast<CUPnPPrintingDevice*>(aWho);
       
    97 		return cbTarget->DoDiscoveryTimeoutL(ETrue);
       
    98 	}
       
    99 
       
   100 
       
   101 //--------------------------------------------------------------------------------------------
       
   102 //
       
   103 // CUPnPPrintingDevice::StatusTimeoutCBL
       
   104 //
       
   105 //--------------------------------------------------------------------------------------------
       
   106 TBool CUPnPPrintingDevice::StatusTimeoutCBL(TAny *aWho)
       
   107 	{
       
   108 		CUPnPPrintingDevice *cbTarget = static_cast<CUPnPPrintingDevice*>(aWho);
       
   109 		TInt res = KErrNone;
       
   110 		TInt err = KErrNone;
       
   111 		TRAP(err, res = cbTarget->DoStatusTimeoutL());
       
   112 		if(KErrNone != err)
       
   113 		{
       
   114 			cbTarget->FinishPrinting(KErrTimedOut, err);
       
   115 			//Don't run the callback again
       
   116 			res = EFalse;
       
   117 		}
       
   118 		return res;
       
   119 	}
       
   120 
       
   121 
       
   122 //--------------------------------------------------------------------------------------------
       
   123 //
       
   124 // CUPnPPrintingDevice::SubmitTimeoutCBL
       
   125 //
       
   126 //--------------------------------------------------------------------------------------------
       
   127 TInt CUPnPPrintingDevice::SubmitTimeoutCBL(TAny *aWho)
       
   128 	{
       
   129 		CUPnPPrintingDevice *cbTarget = static_cast<CUPnPPrintingDevice*>(aWho);
       
   130 		cbTarget->DoSubmitTimeoutL();
       
   131 		return EFalse; // Don't run the callback again
       
   132 	}
       
   133 
       
   134 
       
   135 
       
   136 
       
   137 // ===============================
       
   138 // From MProtPrintingDevice.
       
   139 // ===============================
       
   140 // General
       
   141 //--------------------------------------------------------------------------------------------
       
   142 //
       
   143 // CUPnPPrintingDevice::Version
       
   144 //
       
   145 //--------------------------------------------------------------------------------------------
       
   146 TVersion CUPnPPrintingDevice::Version()
       
   147 	{
       
   148 		LOG("[CUPnPPrintingDevice]\t Version");
       
   149 		return TVersion(KVersionMajor, KVersionMinor, KVersionBuild);
       
   150 	}
       
   151 
       
   152 //--------------------------------------------------------------------------------------------
       
   153 //
       
   154 // CUPnPPrintingDevice::SupportedProtocols
       
   155 //
       
   156 //--------------------------------------------------------------------------------------------
       
   157 TUint CUPnPPrintingDevice::SupportedProtocols()
       
   158 	{
       
   159 	return KImagePrint_PrinterProtocol_UPnP;
       
   160 	}
       
   161 
       
   162 //--------------------------------------------------------------------------------------------
       
   163 //
       
   164 // CUPnPPrintingDevice::RegisterIdleObserver
       
   165 //
       
   166 //--------------------------------------------------------------------------------------------
       
   167 void CUPnPPrintingDevice::RegisterIdleObserver(MProtIdleObserver* /*aObserver*/)
       
   168 {
       
   169 
       
   170 }
       
   171 
       
   172 
       
   173 // Discovery.
       
   174 //--------------------------------------------------------------------------------------------
       
   175 //
       
   176 // CUPnPPrintingDevice::StartDiscoveryL
       
   177 //
       
   178 //--------------------------------------------------------------------------------------------
       
   179 void CUPnPPrintingDevice::StartDiscoveryL(MProtDiscoveryObserver& aObserver, TUint aProtocol)
       
   180 {
       
   181 	LOG("[CUPnPPrintingDevice]\t StartDiscoveryL");
       
   182 	iDiscoveryObserver = &aObserver;
       
   183 	iPrintersFound = EFalse;
       
   184 
       
   185 
       
   186 	TRAPD(err, StartDiscoveryInternalL(aProtocol))
       
   187 	if(KErrNone != err)
       
   188 	{
       
   189 		iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, err, 0);
       
   190 	}
       
   191 		
       
   192 	return;
       
   193 }
       
   194 
       
   195 
       
   196 //--------------------------------------------------------------------------------------------
       
   197 //
       
   198 // CUPnPPrintingDevice::StartDiscoveryL
       
   199 //
       
   200 //--------------------------------------------------------------------------------------------
       
   201 void CUPnPPrintingDevice::StartDiscoveryInternalL(TUint aProtocol)
       
   202 	{
       
   203 		LOG("[CUPnPPrintingDevice]\t StartDiscoveryInternalL");
       
   204 
       
   205 		if (!(aProtocol &  KImagePrint_PrinterProtocol_UPnP))
       
   206 		{
       
   207 			iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, KErrNotSupported, 0);
       
   208 			return;
       
   209 		}
       
   210 
       
   211 		switch ( iState )
       
   212 		{
       
   213 			case EUPnPDiscovery: // Already discovering
       
   214 				break; 
       
   215 			case EUPnPUninitialized:
       
   216 			{
       
   217 				LOG("[CUPnPPrintingDevice]\t starting discovery");				
       
   218 				// (Re)start printer control point
       
   219 				RestartControlPointL();
       
   220 				// No devices available - return printers from cache and start timer
       
   221 				SendPrinterListL(EFalse);				
       
   222 			}
       
   223 				break;
       
   224 			case EUPnPJobReady:
       
   225 			case EUPnPReady:
       
   226 			{
       
   227 				LOG("[CUPnPPrintingDevice]\t returning latest printer list");
       
   228 				SendPrinterListL();
       
   229 			}
       
   230 				break;
       
   231 			case EUPnPCancellingDiscovery:
       
   232 			case EUPnPCancelling:
       
   233 			case EUPnPPrintingStarted:
       
   234 			case EUPnPPrinting:
       
   235 			default:
       
   236 			{
       
   237 				LOG("[CUPnPPrintingDevice]\t cannot start discovery");
       
   238 				iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, KErrInvalidSequence, 0);
       
   239 				break;
       
   240 			}
       
   241 
       
   242 		}
       
   243 	}
       
   244 
       
   245 //--------------------------------------------------------------------------------------------
       
   246 //
       
   247 // CUPnPPrintingDevice::RemoveCachedDeviceL
       
   248 //
       
   249 //--------------------------------------------------------------------------------------------
       
   250 TInt CUPnPPrintingDevice::RemoveCachedDeviceL(TInt aDeviceID)
       
   251 	{
       
   252 		LOG("[CUPnPPrintingDevice::RemoveCachedDeviceL]");
       
   253 		return iPrinterContainer->RemoveCachedDeviceL(aDeviceID);
       
   254 	}
       
   255 
       
   256 //--------------------------------------------------------------------------------------------
       
   257 //
       
   258 // CUPnPPrintingDevice::CancelDiscovery
       
   259 //
       
   260 //--------------------------------------------------------------------------------------------
       
   261 void CUPnPPrintingDevice::CancelDiscovery(TBool aDoCallBack)
       
   262 	{
       
   263 		LOG("[CUPnPPrintingDevice]\t CancelDiscovery");
       
   264 		if (iState == EUPnPDiscovery)
       
   265 		{
       
   266 			iState = EUPnPCancellingDiscovery;
       
   267 			if (aDoCallBack && iDiscoveryObserver)
       
   268 			{
       
   269 				//We're not interested if the call back leaves
       
   270 				TRAP_IGNORE(iDiscoveryObserver->DiscoveryStatusL(EDiscoveryCancelling, KErrNone, 0));
       
   271 			}
       
   272 		
       
   273 			// This needs to be trapped since this function is not named as leaving - no need to chekc the error value
       
   274 			TRAP_IGNORE( DoDiscoveryTimeoutL( EFalse ) );
       
   275 		}
       
   276 	}
       
   277 
       
   278 // Print
       
   279 //--------------------------------------------------------------------------------------------
       
   280 //
       
   281 // CUPnPPrintingDevice::CreatePrintJobL
       
   282 //
       
   283 //--------------------------------------------------------------------------------------------
       
   284 TInt CUPnPPrintingDevice::CreatePrintJobL(TInt aDeviceId, RPointerArray<TDesC>& aImages, MProtPrintEventObserver& aObserver)
       
   285 	{
       
   286 		LOG("[CUPnPPrintingDevice]\t CreatePrintJobL");
       
   287 		iPrintEventObserver = &aObserver;
       
   288 
       
   289 		switch ( iState )
       
   290 		{
       
   291 			case EUPnPReady:
       
   292 			case EUPnPJobReady:
       
   293 			{
       
   294 				LOG("[CUPnPPrintingDevice]\t initializing job container");
       
   295 				InitJobL(aDeviceId, aImages);
       
   296 				return KErrNone;
       
   297 			}
       
   298 			case EUPnPCancelling:
       
   299 			case EUPnPPrintingStarted:
       
   300 			case EUPnPPrinting:
       
   301 			case EUPnPCancellingDiscovery:
       
   302 			case EUPnPUninitialized:
       
   303 			default:
       
   304 			{
       
   305 				LOG("[CUPnPPrintingDevice]\t cannot create job");
       
   306 				break;
       
   307 			}
       
   308 
       
   309 		}
       
   310 		return KErrInvalidSequence;
       
   311 	}
       
   312 
       
   313 //--------------------------------------------------------------------------------------------
       
   314 //
       
   315 // CUPnPPrintingDevice::SubmitPrintJobL
       
   316 //
       
   317 //--------------------------------------------------------------------------------------------
       
   318 void CUPnPPrintingDevice::SubmitPrintJobL()
       
   319 	{
       
   320 
       
   321 		LOG("[CUPnPPrintingDevice]\t SubmitPrintJobL");
       
   322 		TInt err = KErrNone;
       
   323 
       
   324 		switch ( iState )
       
   325 		{
       
   326 			case EUPnPPrintingStarted:
       
   327 			case EUPnPPrinting:
       
   328 				break; 	// Already printing
       
   329 			case EUPnPJobReady:
       
   330 			{
       
   331 				LOG("[CUPnPPrintingDevice]\t submitting jobs");
       
   332 
       
   333 				// Share jobs
       
   334 				TRAP(err, iPrintingJob->ShareImagesL());
       
   335 				if (err != KErrNone)
       
   336 				{
       
   337 					LOG1("[CUPnPPrintingDevice]\t -Sharing failed: %d", err);
       
   338 					break;
       
   339 				}
       
   340 
       
   341 				LOG1("[CUPnPPrintingDevice::SubmitPrintJobL]\t start printing with state=%d", iState);
       
   342 				iState = EUPnPSubmittingJob;
       
   343 				TRAP(err, StartPrintingL());
       
   344 				if (err != KErrNone)
       
   345 					iState = EUPnPJobReady;
       
   346 
       
   347 				LOG1("[CUPnPPrintingDevice::SubmitPrintJobL]\t StartPrintingL leaves with %d", err);
       
   348 				LOG1("[CUPnPPrintingDevice::SubmitPrintJobL]\t state=%d", iState);
       
   349 			}
       
   350 				break;
       
   351 			case EUPnPDiscovery:
       
   352 			case EUPnPCancelling:
       
   353 			case EUPnPCancellingDiscovery:
       
   354 			case EUPnPUninitialized:
       
   355 			case EUPnPReady:
       
   356 			default:
       
   357 			{
       
   358 				LOG("[CUPnPPrintingDevice]\t Invalid sequence to submit job");
       
   359 				err = KErrInvalidSequence;
       
   360 			}
       
   361 				break;
       
   362 		}
       
   363 
       
   364 		if(KErrNone != err)
       
   365 		{
       
   366 			if (iPrintEventObserver)
       
   367 				iPrintEventObserver->PrintJobErrorEvent(EObexSendError, err);
       
   368 			else
       
   369 				User::Leave(err);
       
   370 		}
       
   371 	}
       
   372 
       
   373 //--------------------------------------------------------------------------------------------
       
   374 //
       
   375 // CUPnPPrintingDevice::CancelPrintJob
       
   376 //
       
   377 //--------------------------------------------------------------------------------------------
       
   378 TInt CUPnPPrintingDevice::CancelPrintJob()
       
   379 	{
       
   380 		LOG("[CUPnPPrintingDevice]\t CancelPrintJob");
       
   381 		return DoCancelPrinting();
       
   382 	}
       
   383 
       
   384 //--------------------------------------------------------------------------------------------
       
   385 //
       
   386 // CUPnPPrintingDevice::ContinuePrintJobL
       
   387 //
       
   388 //--------------------------------------------------------------------------------------------
       
   389 TInt CUPnPPrintingDevice::ContinuePrintJobL()
       
   390 	{
       
   391 		return KErrInvalidSequence;
       
   392 	}
       
   393 
       
   394 //--------------------------------------------------------------------------------------------
       
   395 //
       
   396 // CUPnPPrintingDevice::GetNumPrintPages
       
   397 //
       
   398 //--------------------------------------------------------------------------------------------
       
   399 TInt CUPnPPrintingDevice::GetNumPrintPages()
       
   400 {
       
   401 	if( iPrintingJob )
       
   402 		return iPrintingJob->Sheets();
       
   403 	else
       
   404 		return KErrInvalidSequence;
       
   405 }
       
   406 
       
   407 //--------------------------------------------------------------------------------------------
       
   408 //
       
   409 // CUPnPPrintingDevice::GetPrintJobStatus
       
   410 //
       
   411 //--------------------------------------------------------------------------------------------
       
   412 TInt CUPnPPrintingDevice::GetPrintJobStatus()
       
   413 	{
       
   414 		if (iState == EUPnPPrinting)
       
   415 			return KErrInvalidSequence;
       
   416 		return KErrNone;
       
   417 	}
       
   418 
       
   419 //--------------------------------------------------------------------------------------------
       
   420 //
       
   421 // CUPnPPrintingDevice::GetPrinterStatus
       
   422 //
       
   423 //--------------------------------------------------------------------------------------------
       
   424 TInt CUPnPPrintingDevice::GetPrinterStatus(TInt /*aDeviceId*/)
       
   425 	{
       
   426 		return KErrNone;
       
   427 	}
       
   428 
       
   429 //--------------------------------------------------------------------------------------------
       
   430 //
       
   431 // CUPnPPrintingDevice::GetDeviceCapabilityIDsL
       
   432 //
       
   433 //--------------------------------------------------------------------------------------------
       
   434 TInt CUPnPPrintingDevice::GetDeviceCapabilityIDsL(TInt /*aDeviceID*/, RArray<TInt>& aCapabilityIDs)
       
   435 	{
       
   436 		LOG("[CUPnPPrintingDevice]\t GetDeviceCapabilityIDsL");
       
   437 
       
   438 		if (iState == EUPnPUninitialized)
       
   439 		{
       
   440 			LOG("[CUPnPPrintingDevice]\t No devices discovered");
       
   441 			return KErrInvalidSequence;
       
   442 		}
       
   443 
       
   444 		// Return supported settings from XHTML file factory
       
   445 		iPrintFactory->GetCapabilityIDs(aCapabilityIDs);
       
   446 		return KErrNone;
       
   447 	}
       
   448 
       
   449 //--------------------------------------------------------------------------------------------
       
   450 //
       
   451 // CUPnPPrintingDevice::GetDeviceCapabilityL
       
   452 //
       
   453 //--------------------------------------------------------------------------------------------
       
   454 TInt CUPnPPrintingDevice::GetDeviceCapabilityL(TInt /*aDeviceID*/, TInt aCapabilityID, TPrintCapability& aCapability)
       
   455 	{
       
   456 		LOG("[CUPnPPrintingDevice]\t GetDeviceCapabilityL");
       
   457 
       
   458 		if (iState == EUPnPUninitialized)
       
   459 		{
       
   460 			LOG("[CUPnPPrintingDevice]\t No devices discovered");
       
   461 			return KErrInvalidSequence;
       
   462 		}
       
   463 
       
   464 		// Return value from XHTML-print file factory
       
   465 		return iPrintFactory->GetCapability(aCapabilityID, aCapability);
       
   466 	}
       
   467 
       
   468 //--------------------------------------------------------------------------------------------
       
   469 //
       
   470 // CUPnPPrintingDevice::GetJobSetting
       
   471 //
       
   472 //--------------------------------------------------------------------------------------------
       
   473 TInt CUPnPPrintingDevice::GetJobSetting(TInt aCapabilityID, TInt& aValue)
       
   474 	{
       
   475 		LOG("[CUPnPPrintingDevice]\t GetJobSetting");
       
   476 		if (iState != EUPnPJobReady)
       
   477 		{
       
   478 			LOG("[CUPnPPrintingDevice]\t Invalid state");
       
   479 			return KErrInvalidSequence;
       
   480 		}
       
   481 
       
   482 		return iPrintFactory->GetPrintSetting(aCapabilityID, aValue);
       
   483 	}
       
   484 
       
   485 //--------------------------------------------------------------------------------------------
       
   486 //
       
   487 // CUPnPPrintingDevice::SetJobSettingL
       
   488 //
       
   489 //--------------------------------------------------------------------------------------------
       
   490 TInt CUPnPPrintingDevice::SetJobSettingL(TInt aCapabilityID, TInt aValue, TInt& aAffectedCapability)
       
   491 	{
       
   492 		LOG("[CUPnPPrintingDevice]\t SetJobSettingL");
       
   493 		if (iState != EUPnPJobReady)
       
   494 		{
       
   495 			LOG("[CUPnPPrintingDevice]\t Invalid state");
       
   496 			return KErrInvalidSequence;
       
   497 		}
       
   498 
       
   499 		// Set setting in job container
       
   500 		aAffectedCapability = aCapabilityID;
       
   501 		return iPrintFactory->SetPrintSetting(aCapabilityID, aValue);
       
   502 	}
       
   503 
       
   504 //--------------------------------------------------------------------------------------------
       
   505 //
       
   506 // CUPnPPrintingDevice::GetNumPreviewPages
       
   507 //
       
   508 //--------------------------------------------------------------------------------------------
       
   509 TInt CUPnPPrintingDevice::GetNumPreviewPages()
       
   510 	{
       
   511 		return KErrNotSupported;
       
   512 	}
       
   513 
       
   514 //--------------------------------------------------------------------------------------------
       
   515 //
       
   516 // CUPnPPrintingDevice::GetJobTemplateIconL
       
   517 //
       
   518 //--------------------------------------------------------------------------------------------
       
   519 TInt CUPnPPrintingDevice::GetJobTemplateIconL(TInt /*aTemplateID*/, TInt& aFsBitmapHandle)
       
   520 	{
       
   521 		TInt res = KErrNone;
       
   522 
       
   523 		if(iFbsBitmap)
       
   524 			aFsBitmapHandle = iFbsBitmap->Handle();
       
   525 		else
       
   526 		{
       
   527 			iFbsBitmap = new (ELeave) CFbsBitmap();
       
   528 			TFileName iconsFileName;
       
   529 			iconsFileName.Append( KDC_RESOURCE_FILES_DIR );
       
   530 			iconsFileName.Append( KIconsFileName );
       
   531 			res = iFbsBitmap->Load( iconsFileName ,EMbmUpnpiconsIcon );
       
   532 
       
   533 			if( res == KErrNone )
       
   534 				aFsBitmapHandle = iFbsBitmap->Handle();
       
   535 			else
       
   536 			{
       
   537 				aFsBitmapHandle = 0;
       
   538 				delete iFbsBitmap;
       
   539 				iFbsBitmap = NULL;
       
   540 			}
       
   541 		}
       
   542 
       
   543 		return res;
       
   544 	}
       
   545 
       
   546 //--------------------------------------------------------------------------------------------
       
   547 //
       
   548 // CUPnPPrintingDevice::CreatePreviewImage
       
   549 //
       
   550 //--------------------------------------------------------------------------------------------
       
   551 TInt CUPnPPrintingDevice::CreatePreviewImage(TInt /*aPageNumber*/)
       
   552 	{
       
   553 		return KErrNotSupported;
       
   554 	}
       
   555 
       
   556 
       
   557 //--------------------------------------------------------------------------------------------
       
   558 //
       
   559 // CUPnPPrintingDevice::SetNumsOfCopiesL
       
   560 //
       
   561 //--------------------------------------------------------------------------------------------
       
   562 void CUPnPPrintingDevice::SetNumsOfCopiesL( const RArray<TInt>& aNumsOfCopies, TInt& aErr )
       
   563 {
       
   564 	if(iState != EUPnPJobReady)
       
   565 		aErr = KErrInvalidSequence;
       
   566 	else
       
   567 		aErr = iPrintingJob->SetNumsOfCopies(aNumsOfCopies);
       
   568 	
       
   569 	return;
       
   570 }
       
   571 
       
   572 // ==========================================================================================
       
   573 // From MPCPObserver
       
   574 // ==========================================================================================
       
   575 //--------------------------------------------------------------------------------------------
       
   576 //
       
   577 // CUPnPPrintingDevice::CreateJobResponse
       
   578 //
       
   579 //--------------------------------------------------------------------------------------------
       
   580 void CUPnPPrintingDevice::CreateJobResponse( CUpnpAction* aAction, TInt aErrorCode )
       
   581 {
       
   582 	LOG1("[CUPnPPrintingDevice::CreateJobResponse]\t Error: %d", aErrorCode);
       
   583 	
       
   584 	if(!aAction)
       
   585 		return;
       
   586 
       
   587 	if (iState == EUPnPCancelling || iPrintingJob->SessionId() != aAction->SessionId())
       
   588 		return;
       
   589 	
       
   590 	if(KErrNone != aErrorCode)
       
   591 	{
       
   592 		FinishPrinting(EObexConnectError, aErrorCode);
       
   593 		return;
       
   594 	}
       
   595 
       
   596 	ResetTimer();
       
   597     iPrintingJob->SetJobId(aAction->ArgumentValue(KJobId()));
       
   598 
       
   599 	iState = EUPnPPrintingStarted;
       
   600 
       
   601 	TBuf8<KMaxIdLength> id;
       
   602 	iPrintingJob->GetJobId(id);
       
   603 	
       
   604 	LOG("[CUPnPPrintingDevice]\t                                 ******");
       
   605 	LOG81("[CUPnPPrintingDevice]\t -Printing started with job id:  * %S", &id);
       
   606 	LOG("[CUPnPPrintingDevice]\t                                 ******");
       
   607 
       
   608 	// Printing started - restart timer
       
   609 	StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(StatusTimeoutCBL, this) );
       
   610 }
       
   611 
       
   612 
       
   613 //--------------------------------------------------------------------------------------------
       
   614 //
       
   615 // CUPnPPrintingDevice::CancelJobResponse
       
   616 //
       
   617 //--------------------------------------------------------------------------------------------
       
   618 void CUPnPPrintingDevice::CancelJobResponse( CUpnpAction* /*aAction*/, TInt aErrorCode )
       
   619 {
       
   620 	LOG1("[CUPnPPrintingDevice::CancelJobResponse]\t Error: %d", aErrorCode);
       
   621 
       
   622 	FinishPrinting(aErrorCode, KErrNone);
       
   623 	if (iPrintEventObserver && KErrNone == aErrorCode)
       
   624 		iPrintEventObserver->PrintJobProgressEvent(EDone, iPrintingJob->Progress(), ECancelling);
       
   625 }
       
   626 //--------------------------------------------------------------------------------------------
       
   627 //
       
   628 // CUPnPPrintingDevice::GetPrinterAttributesResponse
       
   629 //
       
   630 //--------------------------------------------------------------------------------------------
       
   631 void CUPnPPrintingDevice::GetPrinterAttributesResponse( CUpnpAction* aAction, TInt aErrorCode )
       
   632 {
       
   633 	LOG1("[CUPnPPrintingDevice::GetPrinterAttributesResponse]\t Error: %d", aErrorCode);
       
   634 
       
   635 	if(!aAction)
       
   636 		return;
       
   637 
       
   638 	if (KErrNone != aErrorCode)
       
   639 	{
       
   640 		FinishPrinting(KErrGeneral, aErrorCode);
       
   641 		return;
       
   642 	}
       
   643 
       
   644 	// Cancel and restart timer
       
   645 	// Read printer attributes from action and update job status
       
   646 	TUPnPState state = EStateUnknown;
       
   647 	TRAPD(err, state = iPrintingJob->UpdateJobState(aAction->ArgumentValue( KPrinterState() ),
       
   648 													 aAction->ArgumentValue( KPrinterStateReasons() ),
       
   649 													 aAction->ArgumentValue( KJobIdList() ),
       
   650 													 aAction->ArgumentValue( KJobId() ),
       
   651 													 aAction->ArgumentValue( KSheetsCompleted() ) ) );	
       
   652 	if(KErrNone != err)
       
   653 	{
       
   654 		FinishPrinting(KErrGeneral, err);
       
   655 		return;
       
   656 	}
       
   657 	
       
   658 	UpdatePrintingStatus(state);
       
   659 }
       
   660 
       
   661 
       
   662 //--------------------------------------------------------------------------------------------
       
   663 //
       
   664 // CUPnPPrintingDevice::GetJobAttributesResponse
       
   665 //
       
   666 //--------------------------------------------------------------------------------------------
       
   667 void CUPnPPrintingDevice::GetJobAttributesResponse( CUpnpAction* aAction, TInt aErrorCode )
       
   668 {
       
   669 	LOG1("[CUPnPPrintingDevice::GetJobAttributesResponse]\t Error: %d", aErrorCode);
       
   670 
       
   671 	if (KErrNone != aErrorCode)
       
   672 	{
       
   673 		LOG1("[CUPnPPrintingDevice:.GetJobAttributesResponse]\t - GetPrinterAttributesL with error: %d", aErrorCode);
       
   674 
       
   675 		TInt err = KErrNone;
       
   676 		CUpnpDevice* printer = GetPrinter();
       
   677 		if(!printer)
       
   678 			err = KErrNoMemory;
       
   679 		else
       
   680 			TRAP(err, iPrinterControl->GetPrinterAttributesL(printer));
       
   681 
       
   682 		if(KErrNone != err)
       
   683 			FinishPrinting(KErrGeneral, err);
       
   684 		
       
   685 		return;
       
   686 	}
       
   687 
       
   688 	if(!aAction)
       
   689 		return;
       
   690 	
       
   691 	LOG81("[CUPnPPrintingDevice::GetJobAttributesResponse]\t sheets: ", &(aAction->ArgumentValue( KSheetsCompleted() )));
       
   692 	LOG81("[CUPnPPrintingDevice::GetJobAttributesResponse]\t name: ", &(aAction->ArgumentValue( KJobName() )));
       
   693 	LOG81("[CUPnPPrintingDevice::GetJobAttributesResponse]\t origin: ", &(aAction->ArgumentValue( KUserName() )));
       
   694 	LOG81("[CUPnPPrintingDevice::GetJobAttributesResponse]\t id: ", &(aAction->ArgumentValue( KJobId() )));
       
   695 
       
   696 	TBuf8<KMaxIdLength> id;
       
   697 	iPrintingJob->GetJobId(id);
       
   698 
       
   699 	TUPnPState state = EStateUnknown;
       
   700 	state = iPrintingJob->JobMediaSheetsCompletedUpdated(id, aAction->ArgumentValue( KSheetsCompleted() ) );
       
   701 	
       
   702 	UpdatePrintingStatus(state);
       
   703 }
       
   704 
       
   705 //--------------------------------------------------------------------------------------------
       
   706 //
       
   707 // CUPnPPrintingDevice::GetMarginsResponse
       
   708 //
       
   709 //--------------------------------------------------------------------------------------------
       
   710 void CUPnPPrintingDevice::GetMarginsResponse( CUpnpAction* /*aAction*/, TInt aErrorCode )
       
   711 {
       
   712 	LOG1("[CUPnPPrintingDevice::GetMarginsResponse]\t Error: %d", aErrorCode);
       
   713 	if (KErrNone != aErrorCode)
       
   714 	{
       
   715 		FinishPrinting(KErrGeneral, aErrorCode);
       
   716 		return;
       
   717 	}
       
   718 
       
   719 }
       
   720 
       
   721 //--------------------------------------------------------------------------------------------
       
   722 //
       
   723 // CUPnPPrintingDevice::GetMediaListResponse
       
   724 //
       
   725 //--------------------------------------------------------------------------------------------
       
   726 void CUPnPPrintingDevice::GetMediaListResponse( CUpnpAction* /*aAction*/, TInt aErrorCode )
       
   727 {
       
   728 	LOG1("[CUPnPPrintingDevice::GetMediaListResponse]\t  Error: %d", aErrorCode);
       
   729 	if (KErrNone != aErrorCode)
       
   730 	{
       
   731 		FinishPrinting(KErrGeneral, aErrorCode);
       
   732 		return;
       
   733 	}
       
   734 
       
   735 }
       
   736 
       
   737 //--------------------------------------------------------------------------------------------
       
   738 //
       
   739 // CUPnPPrintingDevice::StateUpdatedResponse
       
   740 //
       
   741 //--------------------------------------------------------------------------------------------
       
   742 void CUPnPPrintingDevice::StateUpdatedResponse( const TDesC8& /*aPrinterState*/, 
       
   743 												const TDesC8& /*aPrinterStateReasons*/,
       
   744                                            		const TDesC8& /*aJobIdList*/, 
       
   745                                            		const TDesC8& /*aJobEndState*/,
       
   746                                            		const TDesC8& /*aJobMediaSheetsCompleted*/, 
       
   747                                            		const TDesC8& /*aJobAbortState*/,
       
   748                                            		const TDesC8& /*aContentCompleteList*/ )
       
   749 {
       
   750 	LOG("[CUPnPPrintingDevice::StateUpdatedResponse]\t");
       
   751 }
       
   752 
       
   753 //--------------------------------------------------------------------------------------------
       
   754 //
       
   755 // CUPnPPrintingDevice::PrinterStateUpdated
       
   756 //
       
   757 //--------------------------------------------------------------------------------------------
       
   758 void CUPnPPrintingDevice::PrinterStateUpdated( const TDesC8& aEvent )
       
   759 {
       
   760 	// no need to check the states: we're not printing
       
   761 	if(EUPnPPrintingStarted != iState && EUPnPPrinting != iState)
       
   762 		return;
       
   763 	
       
   764 	LOG81("[CUPnPPrintingDevice::PrinterStateUpdated]\t:%S",&aEvent);
       
   765 	iStatusTimeout = EFalse;
       
   766 	TUPnPState state = iPrintingJob->PrinterStateUpdated(aEvent);	
       
   767 	UpdatePrintingStatus(state);
       
   768 }
       
   769 
       
   770 //--------------------------------------------------------------------------------------------
       
   771 //
       
   772 // CUPnPPrintingDevice::PrinterStateReasonsUpdated
       
   773 //
       
   774 //--------------------------------------------------------------------------------------------
       
   775 void CUPnPPrintingDevice::PrinterStateReasonsUpdated( const TDesC8& aEvent )
       
   776 {
       
   777 	// no need to check the states: we're not printing
       
   778 	if(EUPnPPrintingStarted != iState && EUPnPPrinting != iState)
       
   779 		return;
       
   780 	
       
   781 	LOG81("[CUPnPPrintingDevice::PrinterStateReasonsUpdated]\t: %S",&aEvent);
       
   782 	iStatusTimeout = EFalse;
       
   783 	TUPnPState state = iPrintingJob->PrinterStateReasonsUpdated(aEvent);	
       
   784 	UpdatePrintingStatus(state);
       
   785 }
       
   786 
       
   787 //--------------------------------------------------------------------------------------------
       
   788 //
       
   789 // CUPnPPrintingDevice::JobIdListUpdated
       
   790 //
       
   791 //--------------------------------------------------------------------------------------------
       
   792 void CUPnPPrintingDevice::JobIdListUpdated( const TDesC8& aEvent )
       
   793 {
       
   794 	// no need to check the states: we're not printing
       
   795 	if(EUPnPPrintingStarted != iState && EUPnPPrinting != iState)
       
   796 		return;
       
   797 	
       
   798 	LOG81("[CUPnPPrintingDevice::JobIdListUpdated]\t:%S",&aEvent);
       
   799 	iStatusTimeout = EFalse;
       
   800 	TUPnPState state = iPrintingJob->JobIdListUpdated(aEvent);	
       
   801 	UpdatePrintingStatus(state);
       
   802 }
       
   803 
       
   804 //--------------------------------------------------------------------------------------------
       
   805 //
       
   806 // CUPnPPrintingDevice::JobEndStateUpdated
       
   807 //
       
   808 //--------------------------------------------------------------------------------------------
       
   809 void CUPnPPrintingDevice::JobEndStateUpdated( const TDesC8& aEvent )
       
   810 {
       
   811 	// no need to check the states: we're not printing
       
   812 	if(EUPnPPrintingStarted != iState && EUPnPPrinting != iState)
       
   813 		return;
       
   814 	
       
   815 	LOG81("[CUPnPPrintingDevice::JobEndStateUpdated]\t:%S",&aEvent);
       
   816 
       
   817 	TUPnPState state = EStateUnknown;
       
   818 	TRAPD(err, state = iPrintingJob->JobEndStateUpdatedL(aEvent));	
       
   819 	if(KErrNone != err)
       
   820 	{
       
   821 		LOG1("[CUPnPPrintingDevice::JobEndStateUpdated]\t leaving with error %d. Continue with timer.",err);
       
   822 		return;
       
   823 	}
       
   824 	
       
   825 	iStatusTimeout = EFalse;
       
   826 	UpdatePrintingStatus(state);
       
   827 }
       
   828 
       
   829 //--------------------------------------------------------------------------------------------
       
   830 //
       
   831 // CUPnPPrintingDevice::JobMediaSheetsCompletedUpdated
       
   832 //
       
   833 //--------------------------------------------------------------------------------------------
       
   834 void CUPnPPrintingDevice::JobMediaSheetsCompletedUpdated( const TDesC8& aEvent )
       
   835 {
       
   836 	// no need to check the states: we're not printing
       
   837 	if(EUPnPPrintingStarted != iState && EUPnPPrinting != iState)
       
   838 		return;
       
   839 	
       
   840 	LOG81("[CUPnPPrintingDevice::JobMediaSheetsCompletedUpdated]\t:%S",&aEvent);
       
   841 	iStatusTimeout = EFalse;
       
   842 	TUPnPState state = iPrintingJob->JobMediaSheetsCompletedUpdated(aEvent);	
       
   843 	UpdatePrintingStatus(state);
       
   844 }
       
   845 
       
   846 //--------------------------------------------------------------------------------------------
       
   847 //
       
   848 // CUPnPPrintingDevice::ContentCompleteListUpdated
       
   849 //
       
   850 //--------------------------------------------------------------------------------------------
       
   851 void CUPnPPrintingDevice::ContentCompleteListUpdated( const TDesC8& aEvent )
       
   852 {
       
   853 	// no need to check the states: we're not printing
       
   854 	if(EUPnPPrintingStarted != iState && EUPnPPrinting != iState)
       
   855 		return;
       
   856 	
       
   857 	LOG81("[CUPnPPrintingDevice::ContentCompleteListUpdated]\t:%S",&aEvent);
       
   858 	iStatusTimeout = EFalse;
       
   859 	TUPnPState state = iPrintingJob->ContentCompleteListUpdated(aEvent);	
       
   860 	UpdatePrintingStatus(state);
       
   861 }
       
   862 
       
   863 //--------------------------------------------------------------------------------------------
       
   864 //
       
   865 // CUPnPPrintingDevice::JobAbortStateUpdated
       
   866 //
       
   867 //--------------------------------------------------------------------------------------------
       
   868 void CUPnPPrintingDevice::JobAbortStateUpdated( const TDesC8& aEvent )
       
   869 {
       
   870 	// no need to check the states: we're not printing
       
   871 	if(EUPnPPrintingStarted != iState && EUPnPPrinting != iState)
       
   872 		return;
       
   873 	
       
   874 	LOG81("[CUPnPPrintingDevice::JobAbortStateUpdated]\t:%S",&aEvent);
       
   875 
       
   876 	TUPnPState state = EStateUnknown;
       
   877 	TRAPD(err, state = iPrintingJob->JobAbortStateUpdatedL(aEvent));	
       
   878 	if(KErrNone != err)
       
   879 	{
       
   880 		LOG1("[CUPnPPrintingDevice::JobAbortStateUpdatedL]\t leaving with error %d. Continue with timer.",err);
       
   881 		return;
       
   882 	}
       
   883 	
       
   884 	iStatusTimeout = EFalse;
       
   885 	UpdatePrintingStatus(state);
       
   886 }
       
   887 
       
   888 //--------------------------------------------------------------------------------------------
       
   889 //
       
   890 // CUPnPPrintingDevice::DeviceDiscoveredL
       
   891 //
       
   892 //--------------------------------------------------------------------------------------------
       
   893 void CUPnPPrintingDevice::DeviceDiscoveredL( CUpnpDevice* aDevice )
       
   894 {
       
   895 
       
   896 	LOG("[CUPnPPrintingDevice::DeviceDiscovered]\t ");
       
   897 	TInt id;
       
   898 	TInt err = KErrNone;
       
   899 
       
   900 	if(!aDevice)
       
   901 		return;
       
   902 	
       
   903 	//Trap this: the iDiscoveryObserver will othervise never know about error
       
   904 	TRAP(err, iPrinterContainer->AddPrinterL(*aDevice, id));
       
   905 
       
   906 	// Inform about error and leave
       
   907 	if(KErrNone != err && KErrAlreadyExists != err)
       
   908 	{
       
   909 		if(iDiscoveryObserver && iState == EUPnPDiscovery)
       
   910 		{
       
   911 			iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, err, 0);
       
   912 		}
       
   913 		User::Leave(err);
       
   914 	}
       
   915 	
       
   916 	iPrintersFound = ETrue;
       
   917 	if (iState == EUPnPUninitialized)
       
   918 	{
       
   919 		iState = EUPnPReady;
       
   920 	}
       
   921 
       
   922 	if(iState == EUPnPDiscovery && iDiscoveryObserver && KErrAlreadyExists != err)
       
   923 	{
       
   924 
       
   925 		TInt index = iPrinterContainer->PrinterIndex(id);
       
   926 		TPrinter printer = iPrinterContainer->ToTPrinter(index);
       
   927 		iDiscoveryObserver->FoundDeviceL(printer);
       
   928 	}
       
   929 	
       
   930 	if (iState == EUPnPSubmittingJob)
       
   931 	{
       
   932 		// Check if the discovered printer is the one we're trying to print with
       
   933 		if (iPrintingJob->PrinterId() == id)
       
   934 		{
       
   935 			// Stop submit timer and submit job
       
   936 			ResetTimer();
       
   937 			TRAP(err, SubmitJobToPcpL(*aDevice, id) );
       
   938 			
       
   939 			// If error occured inform client - leaving not necessary here
       
   940 			if (err != KErrNone)
       
   941 			{
       
   942 				if (iPrintEventObserver)
       
   943 				{
       
   944 					iPrintEventObserver->PrintJobErrorEvent(EObexConnectError, err);
       
   945 				}
       
   946 				iState = EUPnPJobReady;				
       
   947 			}
       
   948 		}
       
   949 	}
       
   950 	LOG("[CUPnPPrintingDevice::DeviceDiscovered]\t -out");
       
   951 }
       
   952 
       
   953 //--------------------------------------------------------------------------------------------
       
   954 //
       
   955 // CUPnPPrintingDevice::DeviceDisappeared
       
   956 //
       
   957 //--------------------------------------------------------------------------------------------
       
   958 void CUPnPPrintingDevice::DeviceDisappeared( CUpnpDevice* aDevice )
       
   959 {
       
   960 	LOG("[CUPnPPrintingDevice]\t DeviceDisappeared");
       
   961 	if ( aDevice )
       
   962 		{
       
   963 		// Notify protocol client if we're in discovery state
       
   964 		if(iState == EUPnPDiscovery && iDiscoveryObserver)
       
   965 		{
       
   966 			TInt index = iPrinterContainer->PrinterIndex( *aDevice );
       
   967 			if (index >= 0)
       
   968 			{
       
   969 				LOG("[CUPnPPrintingDevice]\t informing observer");
       
   970 				TPrinter printer = iPrinterContainer->ToTPrinter(index);
       
   971 				
       
   972 				// Notification needs to be trapped because this is not a leaving function
       
   973 				TRAP_IGNORE(iDiscoveryObserver->RemoveDeviceL(printer));
       
   974 	
       
   975 				iPrinterContainer->RemovePrinter(index);			
       
   976 			}
       
   977 		}
       
   978 		else
       
   979 		{
       
   980 			LOG("[CUPnPPrintingDevice]\t saving to disappeared list");
       
   981 			// Trapped because this is not a leaving function
       
   982 			TRAP_IGNORE(iPrinterContainer->PrinterDisappeared( *aDevice ));
       
   983 		}
       
   984 		}
       
   985 	if ( iPrinterContainer->PrinterCount() < 1 )
       
   986 		{
       
   987 		iPrintersFound = EFalse;
       
   988 		}
       
   989 }
       
   990 
       
   991 
       
   992 /////////////////////////
       
   993 // Protected.
       
   994 /////////////////////////
       
   995 
       
   996 
       
   997 /////////////////////////
       
   998 // Private.
       
   999 /////////////////////////
       
  1000 //--------------------------------------------------------------------------------------------
       
  1001 //
       
  1002 // CUPnPPrintingDevice::CUPnPPrintingDevice
       
  1003 //
       
  1004 //--------------------------------------------------------------------------------------------
       
  1005 CUPnPPrintingDevice::CUPnPPrintingDevice()
       
  1006 	{
       
  1007 		iPrinterTimer = NULL;
       
  1008 		iState = EUPnPUninitialized;
       
  1009 		iPrintersFound = EFalse;
       
  1010 		iTriedReadCacheAndFail = EFalse;
       
  1011 		ResetTimer();
       
  1012 	}
       
  1013 
       
  1014 //--------------------------------------------------------------------------------------------
       
  1015 //
       
  1016 // CUPnPPrintingDevice::RestartControlPointL
       
  1017 //
       
  1018 //--------------------------------------------------------------------------------------------
       
  1019 void CUPnPPrintingDevice::RestartControlPointL()
       
  1020 	{
       
  1021 		if (iPrinterControl)
       
  1022 		{
       
  1023 			delete iPrinterControl;
       
  1024 			iPrinterControl = NULL;
       
  1025 		}
       
  1026  
       
  1027 		iFriendlyName.Copy(KUPnPUserName());
       
  1028 		
       
  1029 	CUpnpSettings *rep = CUpnpSettings::NewL( KCRUidUPnPStack );
       
  1030     CleanupStack::PushL(rep);
       
  1031 		//Get Access Point from central repository
       
  1032     TInt iapId = -1;
       
  1033     User::LeaveIfError( rep->Get( CUpnpSettings::KUPnPStackIapId, iapId ));
       
  1034     
       
  1035     //Check accessPoint and leave if not ok
       
  1036     if( iapId < 0 )
       
  1037     {
       
  1038       if(iDiscoveryObserver)
       
  1039         iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, KErrAbort, 0);
       
  1040       User::Leave( KErrAbort );
       
  1041     }
       
  1042 
       
  1043 		CleanupStack::PopAndDestroy(rep);
       
  1044 		
       
  1045 
       
  1046     // Create printer control point - search starts right away
       
  1047 		LOG("[CUPnPPrintingDevice]\t - Printer control point");
       
  1048 		iPrinterControl = CPrinterControlPoint::NewL(*this);
       
  1049 	}
       
  1050 
       
  1051 
       
  1052 //--------------------------------------------------------------------------------------------
       
  1053 //
       
  1054 // CUPnPPrintingDevice::SendPrinterListL
       
  1055 //
       
  1056 //--------------------------------------------------------------------------------------------
       
  1057 void CUPnPPrintingDevice::SendPrinterListL(TBool aSync)
       
  1058 {
       
  1059 LOG("[CUPnPPrintingDevice]\t SendPrinterListL Begin");
       
  1060 	TInt err = KErrNone;
       
  1061 	if (aSync)
       
  1062 	{
       
  1063 		// Remove disappeared devices from array
       
  1064 		iPrinterContainer->SyncPrinterArray();
       
  1065 	}
       
  1066 
       
  1067 	if (iPrinterContainer->PrinterCount() < 1 && !iTriedReadCacheAndFail)
       
  1068 	{
       
  1069 		// Read printer cache
       
  1070 		LOG("[CUPnPPrintingDevice]\t SendPrinterListL xxx trying read cache file");
       
  1071 		TRAP(err, iPrinterContainer->ReadCacheL());
       
  1072 		if(KErrNone != err)
       
  1073 		{
       
  1074 			LOG1("[CUPnPPrintingDevice]\t SendPrinterListL xxx some error file reading %d", err);
       
  1075 			if(err == KErrNotFound)
       
  1076 			{
       
  1077 				iPrintersFound = EFalse;
       
  1078 				iTriedReadCacheAndFail = ETrue;
       
  1079 			} 
       
  1080 			else 
       
  1081 				User::Leave(err);
       
  1082 		} 
       
  1083 		else
       
  1084 		{
       
  1085 			LOG("[CUPnPPrintingDevice]\t SendPrinterListL xxx cachefile readed");
       
  1086 			iPrintersFound = EFalse;
       
  1087 		}
       
  1088 		
       
  1089 		if(aSync)
       
  1090 		{
       
  1091 			RestartControlPointL();
       
  1092 		}
       
  1093 	}
       
  1094 	
       
  1095 	if (iPrinterContainer->PrinterCount() > 0 && iDiscoveryObserver)
       
  1096 	{
       
  1097 		for (TInt i=0; i< iPrinterContainer->PrinterCount(); i++)
       
  1098 		{
       
  1099 			TPrinter t = iPrinterContainer->ToTPrinter(i);
       
  1100 			iDiscoveryObserver->FoundDeviceL( t );
       
  1101 		}
       
  1102 	}
       
  1103 
       
  1104 	if (!iPrintersFound)
       
  1105 	{
       
  1106 		// start timed search
       
  1107 		StartTimer(KPrinterDiscoveryTimeout, KPrinterDiscoveryTimeout, TCallBack(DiscoveryTimeoutCBL, this) );
       
  1108 		iState = EUPnPDiscovery;
       
  1109 		iTriedReadCacheAndFail = EFalse;
       
  1110 	}
       
  1111 	else if(iDiscoveryObserver)
       
  1112 	{
       
  1113 		iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, KErrNone, 0);	
       
  1114 	}
       
  1115 	else
       
  1116     {
       
  1117 	    User::LeaveIfNull(iDiscoveryObserver);
       
  1118     }
       
  1119 	LOG("[CUPnPPrintingDevice]\t SendPrinterListL end");
       
  1120 }
       
  1121 
       
  1122 //--------------------------------------------------------------------------------------------
       
  1123 //
       
  1124 // CUPnPPrintingDevice::DoDiscoveryTimeoutL
       
  1125 //
       
  1126 //--------------------------------------------------------------------------------------------
       
  1127 TBool CUPnPPrintingDevice::DoDiscoveryTimeoutL(TBool aDoCallBack)
       
  1128 {
       
  1129 	LOG("[CUPnPPrintingDevice]\t DoDiscoveryTimeOut");
       
  1130 
       
  1131 	ResetTimer();
       
  1132 	switch( iState )
       
  1133 	{
       
  1134 		case EUPnPCancellingDiscovery:
       
  1135 			{
       
  1136 				LOG("[CUPnPPrintingDevice]\t cancelling discovery");
       
  1137 				
       
  1138 				if (iPrinterContainer->PrinterCount() > 0)
       
  1139 				{
       
  1140 					iPrintersFound = ETrue;
       
  1141 				}
       
  1142 				
       
  1143 				if (aDoCallBack && iDiscoveryObserver)
       
  1144 				{
       
  1145 					iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, KErrNone, 0);
       
  1146 				}
       
  1147 				
       
  1148 			}
       
  1149 			break;
       
  1150 		case EUPnPDiscovery:
       
  1151 			{
       
  1152 				LOG("[CUPnPPrintingDevice]\t discovery timeout");
       
  1153 				
       
  1154 				// Notify about cached devices, which weren't discovered
       
  1155 				RPointerArray<CUPPrinter> cachedPrinters;
       
  1156 				CleanupClosePushL(cachedPrinters);
       
  1157 				iPrinterContainer->GetDisappearedPrinters(cachedPrinters);
       
  1158 				for (TInt i=0; i < cachedPrinters.Count(); i++)
       
  1159 				{
       
  1160 					TPrinter printer = cachedPrinters[i]->ToTPrinter();
       
  1161 					iDiscoveryObserver->RemoveDeviceL(printer);		
       
  1162 				}
       
  1163 				
       
  1164 				CleanupStack::PopAndDestroy(); //cachedPrinters
       
  1165 
       
  1166 				// Remove disappeared printers and cached printers, which weren't found printers from container
       
  1167 				iPrinterContainer->SyncPrinterArray();
       
  1168 
       
  1169         if (iPrinterContainer->PrinterCount() > 0)
       
  1170 				{
       
  1171 					iPrintersFound = ETrue;
       
  1172 				}
       
  1173 
       
  1174 				// Notify client's observer
       
  1175 				if (aDoCallBack && iDiscoveryObserver)
       
  1176 					iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, KErrNone, 0);
       
  1177 				
       
  1178 			}
       
  1179 			break;
       
  1180 		default:
       
  1181 			break;
       
  1182 	}
       
  1183 
       
  1184 	if (!iPrintersFound)
       
  1185 	{
       
  1186 		LOG("[CUPnPPrintingDevice]\t no printers found");
       
  1187 		iState = EUPnPUninitialized;
       
  1188 	}
       
  1189 	else
       
  1190 	{
       
  1191 		iState = EUPnPReady;
       
  1192 	}
       
  1193 
       
  1194 	//Don't run this callback again
       
  1195 	return EFalse;
       
  1196 }
       
  1197 
       
  1198 //--------------------------------------------------------------------------------------------
       
  1199 //
       
  1200 // CUPnPPrintingDevice::DoStatusTimeoutL
       
  1201 //
       
  1202 //--------------------------------------------------------------------------------------------
       
  1203 TBool CUPnPPrintingDevice::DoStatusTimeoutL()
       
  1204 {
       
  1205 	LOG("[CUPnPPrintingDevice]\t DoStatusTimeOut");
       
  1206 
       
  1207 	if (iState == EUPnPCancelling || iState == EUPnPSubmittingJob)
       
  1208 	{
       
  1209 		// Printer did not response to cancel or create job
       
  1210 		LOG("[CUPnPPrintingDevice]\t - no response for cancel or create.");
       
  1211 		FinishPrinting(KErrGeneral, EPbCheckPrinter);
       
  1212 		return EFalse; // do not call again
       
  1213 	}
       
  1214 
       
  1215 	if (iState == EUPnPPrinting || iState == EUPnPPrintingStarted)
       
  1216 	{
       
  1217 		--iPendingCount;
       
  1218 
       
  1219 		// No printing status notifications received
       
  1220 		CUpnpDevice* printer = GetPrinter();
       
  1221 		if (!printer || iStatusTimeout || 0 > iPendingCount)
       
  1222 		{
       
  1223 			// print error - cancel printing
       
  1224 			LOG("[CUPnPPrintingDevice]\t - print error - cancel printing.");
       
  1225 			LOG1("[CUPnPPrintingDevice]\t - iStatusTimeout: %d", iStatusTimeout);
       
  1226 			LOG1("[CUPnPPrintingDevice]\t - iPendingCount: %d", iPendingCount);
       
  1227 			ResetTimer();
       
  1228 	  		if (iPrintEventObserver)
       
  1229 				iPrintEventObserver->PrintJobErrorEvent(KErrTimedOut, EPbCheckPrinter);
       
  1230 			DoCancelPrinting();
       
  1231 			return EFalse; // do not call again
       
  1232 		}
       
  1233 
       
  1234 		iStatusTimeout = ETrue;
       
  1235 		
       
  1236 		LOG1("[CUPnPPrintingDevice]\t - GetPrinterAttributesL with iState: %d", iState);
       
  1237 		iPrinterControl->GetPrinterAttributesL(printer);
       
  1238 
       
  1239 		/*LOG1("[CUPnPPrintingDevice]\t - GetJobAttributesL with iState: %d", iState);
       
  1240 		TBuf8<KMaxIdLength> id;
       
  1241 		iPrintingJob->GetJobId(id);
       
  1242 		iPrinterControl->GetJobAttributesL(printer, id);*/
       
  1243 	}
       
  1244 
       
  1245 	return ETrue; // call again
       
  1246 }
       
  1247 
       
  1248 
       
  1249 
       
  1250 //--------------------------------------------------------------------------------------------
       
  1251 //
       
  1252 // CUPnPPrintingDevice::InitJobL
       
  1253 //
       
  1254 //--------------------------------------------------------------------------------------------
       
  1255 void CUPnPPrintingDevice::InitJobL(TInt aDeviceId, RPointerArray<TDesC>& aImages)
       
  1256 {
       
  1257 	LOG("[CUPnPPrintingDevice::InitJobL]\t");
       
  1258 
       
  1259 	// Check that device exists
       
  1260 	CUPPrinter* printer = iPrinterContainer->Printer(aDeviceId);
       
  1261 	if (!printer)
       
  1262 	{
       
  1263 		LOG("[CUPnPPrintingDevice]\t printer not found");
       
  1264 		User::Leave(KErrArgument);
       
  1265 	}
       
  1266 
       
  1267 	// Create job
       
  1268 	if (iPrintingJob)
       
  1269 	{
       
  1270 		delete iPrintingJob;
       
  1271 		iPrintingJob = NULL;
       
  1272 	}
       
  1273 
       
  1274 	// Change format of file list
       
  1275 	RArray<TFileName> imageList;
       
  1276 	CleanupClosePushL(imageList);
       
  1277 	for (TInt i=0; i < aImages.Count(); i++)
       
  1278 	{
       
  1279 		LOG81("[InitJobL]\t ", aImages[i]);
       
  1280 		imageList.Append( *(aImages[i]) );
       
  1281 	}
       
  1282 
       
  1283 	// Create job object
       
  1284 	iPrintingJob = CUPPrintingJob::NewL(printer, imageList, iPrintFactory, iFriendlyName);
       
  1285 	CleanupStack::PopAndDestroy(&imageList);
       
  1286 
       
  1287 	// Update state and return
       
  1288 	iState = EUPnPJobReady;
       
  1289 }
       
  1290 
       
  1291 //--------------------------------------------------------------------------------------------
       
  1292 //
       
  1293 // CUPnPPrintingDevice::StartPrintingL
       
  1294 //
       
  1295 //--------------------------------------------------------------------------------------------
       
  1296 void CUPnPPrintingDevice::StartPrintingL()
       
  1297 {
       
  1298 	LOG("[CUPnPPrintingDevice::StartPrintingL]\t");
       
  1299 	ResetTimer();
       
  1300 
       
  1301 	// Get pointer to correct CDevice
       
  1302 	CUPPrinter* upPrinter = static_cast<CUPPrinter*>(User::LeaveIfNull(
       
  1303 					iPrinterContainer->Printer(iPrintingJob->PrinterId())));
       
  1304 
       
  1305 	CUpnpDevice* printer = upPrinter->Device();
       
  1306 
       
  1307 	if (!printer)
       
  1308 	{
       
  1309 		LOG("[CUPnPPrintingDevice]\t -UPnP Printer pointer was NULL");
       
  1310 		
       
  1311 		// Try to discover selected printer - start timer
       
  1312 		StartTimer(KPrinterSubmitTimeout, KPrinterSubmitTimeout, TCallBack(SubmitTimeoutCBL, this) );
       
  1313 		return;
       
  1314 	} 
       
  1315 
       
  1316 	// Send create job to PCP
       
  1317 	SubmitJobToPcpL(*printer, iPrintingJob->PrinterId());
       
  1318 }
       
  1319 
       
  1320 //--------------------------------------------------------------------------------------------
       
  1321 //
       
  1322 // CUPnPPrintingDevice::DoSubmitTimeoutL
       
  1323 //
       
  1324 //--------------------------------------------------------------------------------------------
       
  1325 void CUPnPPrintingDevice::DoSubmitTimeoutL()
       
  1326 {
       
  1327 	LOG("[CUPnPPrintingDevice]\t CUPnPPrintingDevice::DoSubmitTimeoutL");
       
  1328 
       
  1329 	ResetTimer();
       
  1330 
       
  1331 	TRAPD(err, SubmitJobToPcpL(iPrintingJob->PrinterId()));				
       
  1332 		
       
  1333 	if( err != KErrNone)
       
  1334 	{
       
  1335 		if (iPrintEventObserver)
       
  1336 			iPrintEventObserver->PrintJobErrorEvent(EObexConnectError, err);
       
  1337 		iState = EUPnPJobReady;
       
  1338 	}
       
  1339 	
       
  1340 }
       
  1341 
       
  1342 
       
  1343 
       
  1344 //--------------------------------------------------------------------------------------------
       
  1345 //
       
  1346 // CUPnPPrintingDevice::SubmitJobToPcpL
       
  1347 //
       
  1348 //--------------------------------------------------------------------------------------------
       
  1349 void CUPnPPrintingDevice::SubmitJobToPcpL(TInt aDeviceID)
       
  1350 {
       
  1351 	LOG("[CUPnPPrintingDevice::SubmitJobToPcpL(TInt)]\t");
       
  1352 
       
  1353 	// Get pointer to correct CDevice
       
  1354 	CUPPrinter* printer = NULL;
       
  1355 
       
  1356 	TInt printerIndex = iPrinterContainer->PrinterIndex(aDeviceID);
       
  1357 	if (printerIndex >= 0)
       
  1358 	{
       
  1359 		printer =
       
  1360 			static_cast<CUPPrinter*> (User::LeaveIfNull(iPrinterContainer->Printer(printerIndex)));
       
  1361         SubmitJobToPcpL(*(printer->Device()), aDeviceID);
       
  1362 	}
       
  1363 	else
       
  1364 	{
       
  1365 	    User::LeaveIfNull(printer);
       
  1366     }
       
  1367 	
       
  1368 }
       
  1369 
       
  1370 //--------------------------------------------------------------------------------------------
       
  1371 //
       
  1372 // CUPnPPrintingDevice::SubmitJobToPcpL
       
  1373 //
       
  1374 //--------------------------------------------------------------------------------------------
       
  1375 void CUPnPPrintingDevice::SubmitJobToPcpL(CUpnpDevice& aPrinter, TInt aPrinterID)
       
  1376 {
       
  1377 	LOG("[CUPnPPrintingDevice::SubmitJobToPcpL(CDevice&, TInt)]\t");
       
  1378 
       
  1379 	// Init settings
       
  1380 	TPtrC8 userName;
       
  1381 	iPrintingJob->GetUserName(userName);
       
  1382 
       
  1383 	// Get and convert xhtml file
       
  1384 	TFileName8 fileName;
       
  1385 
       
  1386 	LOG("[CUPnPPrintingDevice::SubmitJobToPcpL]\t -before GetPrintFileL call");
       
  1387 	iPrintingJob->GetPrintFileL(fileName);
       
  1388 	LOG("[CUPnPPrintingDevice::SubmitJobToPcpL]\t -after GetPrintFile call");
       
  1389 	
       
  1390 	User::LeaveIfNull(&aPrinter);
       
  1391 	
       
  1392 	LOG("[CUPnPPrintingDevice::SubmitJobToPcpL]\t -before CreateJobL call");
       
  1393 	TInt sessionId = iPrinterControl->CreateJobL(&aPrinter, fileName, userName, KUPnPOne(), KUPnPDeviceSetting(),
       
  1394 					 KUPnPDeviceSetting(), KUPnPDeviceSetting(), KUPnPDeviceSetting(), KUPnPDeviceSetting(), KUPnPDeviceSetting());
       
  1395 	LOG("[CUPnPPrintingDevice::SubmitJobToPcpL]\t -after CreateJobL call");
       
  1396 	
       
  1397 	iPrintingJob->SetSessionId(sessionId);
       
  1398 	iPendingCount = KPendingLimit + iPrintingJob->ImageCount();
       
  1399 
       
  1400 	LOG1("[CUPnPPrintingDevice]\t -Printing started successfully - timer can expire %d times", iPendingCount);
       
  1401 
       
  1402 	//Add printer in cache if doesn't exist
       
  1403 	iPrinterContainer->UpdateCacheL(aPrinterID);
       
  1404 
       
  1405 	StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(StatusTimeoutCBL, this) );
       
  1406 }
       
  1407 
       
  1408 //--------------------------------------------------------------------------------------------
       
  1409 //
       
  1410 // CUPnPPrintingDevice::DoCancelPrintJob()
       
  1411 //
       
  1412 //--------------------------------------------------------------------------------------------
       
  1413 TInt CUPnPPrintingDevice::DoCancelPrinting()
       
  1414 {
       
  1415 	LOG("[CUPnPPrintingDevice]\t DoCancelPrinting()");
       
  1416 
       
  1417 	if (iState == EUPnPPrintingStarted || iState == EUPnPPrinting || iState == EUPnPSubmittingJob)
       
  1418 	{
       
  1419 		// Cancel printer response timer first
       
  1420 		LOG("[CUPnPPrintingDevice]\t -Canceling timer");
       
  1421 		ResetTimer();
       
  1422 
       
  1423 		// Cancel current job
       
  1424 		iState = EUPnPCancelling;
       
  1425 		CUpnpDevice* printer = GetPrinter();
       
  1426 		if (!printer)
       
  1427 		{
       
  1428 			LOG("[CUPnPPrintingDevice]\t Invalid printer");
       
  1429 			return KErrArgument;
       
  1430 		}
       
  1431 
       
  1432 		TInt err;
       
  1433 		TBuf8<KMaxIdLength> id;
       
  1434 		iPrintingJob->GetJobId(id);
       
  1435 	
       
  1436 		if (id.Length() >= 1)
       
  1437 		{
       
  1438 			LOG81("[CUPnPPrintingDevice]\t Cancel with job id %S", &id);
       
  1439 			TRAP(err, iPrinterControl->CancelJobL(printer, id))
       
  1440 		}
       
  1441 		else
       
  1442 		{
       
  1443 			LOG81("[CUPnPPrintingDevice]\t Cancel with session id %S", iPrintingJob->SessionId());
       
  1444 			TRAP(err, iPrinterControl->CancelJobL(iPrintingJob->SessionId()) );
       
  1445 		}
       
  1446 
       
  1447 		if(KErrNone != err)
       
  1448 		{
       
  1449 			LOG1("[CUPnPPrintingDevice]\t Cancel failed with error %d -> roughly finish printing ", err);
       
  1450 			FinishPrinting(KErrGeneral, err);
       
  1451 			return err;
       
  1452 		}
       
  1453 
       
  1454 		// Start timer for cancel response
       
  1455 		StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(StatusTimeoutCBL, this) );
       
  1456 
       
  1457 		return KErrNone;
       
  1458 	}
       
  1459 
       
  1460 	if (iState == EUPnPJobReady)
       
  1461 	{
       
  1462 		return KErrNone;
       
  1463 	}
       
  1464 
       
  1465 	return KErrInvalidSequence;
       
  1466 }
       
  1467 
       
  1468 //--------------------------------------------------------------------------------------------
       
  1469 //
       
  1470 // CUPnPPrintingDevice::UpdatePrintingStatus()
       
  1471 //
       
  1472 //--------------------------------------------------------------------------------------------
       
  1473 void CUPnPPrintingDevice::UpdatePrintingStatus(TUPnPState aJobState)
       
  1474 {
       
  1475 	LOG1("[CUPnPPrintingDevice::UpdatePrintingStatus]\t - JobState: %d", aJobState);
       
  1476 
       
  1477 	/* Printer stopped */
       
  1478 	if(EPrinterStateStopped == aJobState || EStatePending == aJobState)
       
  1479 	{
       
  1480 		iStatusTimeout = EFalse;
       
  1481 		// Finish printing if reason found. Otherwise wait timer or new message
       
  1482 		if(ENoMessage != iPrintingJob->JobState()->Reason())
       
  1483 		{
       
  1484 			LOG1("[CUPnPPrintingDevice]\t - state NOK -> Cancel with %d", iPrintingJob->JobStateReason());
       
  1485 	  		if (iPrintEventObserver)
       
  1486 	  			iPrintEventObserver->PrintJobErrorEvent(KErrGeneral, iPrintingJob->JobStateReason());
       
  1487 			DoCancelPrinting();
       
  1488 		}
       
  1489 		return;
       
  1490 	}
       
  1491 
       
  1492 	// Job aborted
       
  1493 	if(EJobStateAborted == aJobState)
       
  1494 	{
       
  1495 		LOG("[CUPnPPrintingDevice]\t - EJobStateAborted -> Finish");
       
  1496 		FinishPrinting(KErrGeneral, iPrintingJob->JobStateReason());
       
  1497 		return;
       
  1498 	}
       
  1499 
       
  1500 	if(EStateReady == aJobState)
       
  1501 	{
       
  1502 		// Printing finished for current job
       
  1503 		LOG("[CUPnPPrintingDevice]\t - Printing finished");
       
  1504 		iPrintEventObserver->PrintJobProgressEvent(EDone, iPrintingJob->Progress(), ENoMessage);
       
  1505 
       
  1506 		// FinishPrinting
       
  1507 		FinishPrinting();
       
  1508   		return;
       
  1509 	}
       
  1510 
       
  1511 	iPrintEventObserver->PrintJobProgressEvent(EActive, iPrintingJob->Progress(), ENoMessage);
       
  1512 	iStatusTimeout = EFalse;
       
  1513 	LOG("[CUPnPPrintingDevice::UpdatePrintingStatus]\t - out");
       
  1514 }
       
  1515 
       
  1516 //--------------------------------------------------------------------------------------------
       
  1517 //
       
  1518 // CUPnPPrintingDevice::FinishPrinting
       
  1519 //
       
  1520 //--------------------------------------------------------------------------------------------
       
  1521 void CUPnPPrintingDevice::FinishPrinting()
       
  1522 {
       
  1523 	LOG("[CUPnPPrintingDevice::FinishPrinting]\t ");
       
  1524 
       
  1525 	LOG("[CUPnPPrintingDevice]\t -Reset timer");
       
  1526 	ResetTimer();
       
  1527 
       
  1528 	LOG("[CUPnPPrintingDevice]\t -Unshare");
       
  1529 	iPrintingJob->UnShareImages();
       
  1530 
       
  1531 	LOG("[CUPnPPrintingDevice]\t -Init ids");
       
  1532 	iPrintingJob->SetJobId(KNullDesC8());
       
  1533 	iPrintingJob->SetSessionId(KErrNotFound);
       
  1534 	iPendingCount = KPendingLimit;
       
  1535 
       
  1536 	LOG("[CUPnPPrintingDevice]\t -Update state");
       
  1537 	if(NULL != GetPrinter())
       
  1538 		iState = EUPnPJobReady;
       
  1539 	else
       
  1540 		iState = EUPnPReady;
       
  1541 	LOG1("[CUPnPPrintingDevice]\t FinishPrinting: state=%d", iState);
       
  1542 
       
  1543 
       
  1544 	// Inform control point
       
  1545 	// No can do if this leaves -> ignore leave
       
  1546 	TRAP_IGNORE(iPrinterControl->PrintingFinishedL(GetPrinter()));
       
  1547 	LOG("[CUPnPPrintingDevice::FinishPrinting]\t -out");
       
  1548 }
       
  1549 
       
  1550 //--------------------------------------------------------------------------------------------
       
  1551 //
       
  1552 // CUPnPPrintingDevice::FinishPrinting
       
  1553 //
       
  1554 //--------------------------------------------------------------------------------------------
       
  1555 void CUPnPPrintingDevice::FinishPrinting(TInt aErrorCode, TInt aErrorMessage)
       
  1556 {
       
  1557 	FinishPrinting();
       
  1558 
       
  1559 	if (iPrintEventObserver && KErrNone != aErrorCode)
       
  1560 		iPrintEventObserver->PrintJobErrorEvent(aErrorCode, aErrorMessage);
       
  1561 }
       
  1562 
       
  1563 //--------------------------------------------------------------------------------------------
       
  1564 //
       
  1565 // CUPnPPrintingDevice::GetPrinter
       
  1566 //
       
  1567 //--------------------------------------------------------------------------------------------
       
  1568 CUpnpDevice* CUPnPPrintingDevice::GetPrinter()
       
  1569 {
       
  1570 	LOG("[CUPnPPrintingDevice::GetPrinter]");
       
  1571 
       
  1572 	if(iPrintingJob)
       
  1573 	{
       
  1574 		CUPPrinter* uaPrinter = iPrinterContainer->Printer(iPrintingJob->PrinterId());
       
  1575 		if (uaPrinter)
       
  1576 		{
       
  1577 			return uaPrinter->Device();
       
  1578 		}
       
  1579 	}
       
  1580 	return NULL;
       
  1581 }
       
  1582 
       
  1583 //--------------------------------------------------------------------------------------------
       
  1584 //
       
  1585 // CUPnPPrintingDevice::ResetTimer
       
  1586 //
       
  1587 //--------------------------------------------------------------------------------------------
       
  1588 void CUPnPPrintingDevice::ResetTimer()
       
  1589 {
       
  1590 	LOG("[CUPnPPrintingDevice::ResetTimer]\t");
       
  1591 
       
  1592 	if(iPrinterTimer)
       
  1593 		iPrinterTimer->Cancel();
       
  1594 	iStatusTimeout = EFalse;
       
  1595 }
       
  1596 
       
  1597 //--------------------------------------------------------------------------------------------
       
  1598 //
       
  1599 // CUPnPPrintingDevice::ResetTimer
       
  1600 //
       
  1601 //--------------------------------------------------------------------------------------------
       
  1602 void CUPnPPrintingDevice::StartTimer(TTimeIntervalMicroSeconds32 aDelay,
       
  1603 									 TTimeIntervalMicroSeconds32 anInterval,
       
  1604 									 TCallBack aCallBack)
       
  1605 {
       
  1606 	LOG("[CUPnPPrintingDevice::StartTimer]\t");
       
  1607 
       
  1608 	ResetTimer();
       
  1609 
       
  1610 	iPrinterTimer->Start(aDelay, anInterval, aCallBack );
       
  1611 
       
  1612 }
       
  1613 
       
  1614 //  End of File