ImagePrint/ImagePrintEngine/DeviceProtocols/upnpprotocolfw2/src/cupprintingjob.cpp
branchRCL_3
changeset 20 159fc2f68139
parent 17 26673e532f65
child 21 d59c248c9d36
equal deleted inserted replaced
17:26673e532f65 20: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 CUPPrintingJob class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <upnpdevice.h>
       
    20 #include <escapeutils.h> //utf8 conversions
       
    21 #include <upnpprotocolinfo.h>
       
    22 #include <upnpmediaserversettings.h>
       
    23 
       
    24 #include "cupprintingjob.h"
       
    25 #include "cupprinter.h"
       
    26 #include "cuplogger.h"
       
    27 #include "cupprintfactory.h"
       
    28 #include "printcapabilitycodes.h"
       
    29 #include "cupfilesharingactive.h"
       
    30 
       
    31 
       
    32 
       
    33 _LIT8(KResource, "res");
       
    34 _LIT(KMediaTypes, "image/jpeg:*,audio/mpeg:MP3,audio/mp4:AAC_ISO_320,video/mp4:AVC_MP4_BL_CIF15_AAC_520,application/vnd.pwg-xhtml-print+xml:*");
       
    35 
       
    36 // Public functions
       
    37 //--------------------------------------------------------------------------------------------
       
    38 //
       
    39 // CUPPrintingJob::NewL
       
    40 //
       
    41 //--------------------------------------------------------------------------------------------
       
    42 CUPPrintingJob* CUPPrintingJob::NewL(CUPPrinter* aPrinter, RArray<TFileName>& aImages, 
       
    43 									 CUPPrintFactory* aFileFactory, const TDesC8& aUserName)
       
    44 {
       
    45 	CUPPrintingJob* self = new (ELeave) CUPPrintingJob(aFileFactory);
       
    46 	CleanupStack::PushL(self);
       
    47 	self->ConstructL(aPrinter, aImages, aUserName);
       
    48 	CleanupStack::Pop();	// self
       
    49 	return self;
       
    50 }
       
    51 
       
    52 
       
    53 //--------------------------------------------------------------------------------------------
       
    54 //
       
    55 // CUPPrintingJob::~CUPPrintingJob
       
    56 //
       
    57 //--------------------------------------------------------------------------------------------
       
    58 CUPPrintingJob::~CUPPrintingJob()
       
    59 {
       
    60 	// Stop sharing
       
    61 	UnShareImages();
       
    62   
       
    63   if(iFileSharing)
       
    64   	delete iFileSharing;
       
    65   
       
    66   if(iOrgMediaServerStatus != RUpnpMediaServerClient::EStartedOnline)
       
    67   {
       
    68   	iMediaServerClient.Stop();
       
    69   	if(iOrgMediaServerStatus == RUpnpMediaServerClient::EStartedOffline)
       
    70   	{
       
    71   	  iMediaServerClient.StartOffline();
       
    72   	}
       
    73   }
       
    74   
       
    75   iMediaServerClient.Close();
       
    76   
       
    77 	iImages.Close();
       
    78 
       
    79 	if(iJobState)
       
    80 		delete iJobState;
       
    81 }
       
    82 
       
    83 //--------------------------------------------------------------------------------------------
       
    84 //
       
    85 // CUAPrintingJob::SetSessionId
       
    86 //
       
    87 //--------------------------------------------------------------------------------------------
       
    88 void CUPPrintingJob::SetSessionId(TInt aId)
       
    89 {
       
    90 	iSessionId = aId;
       
    91 }
       
    92 
       
    93 
       
    94 //--------------------------------------------------------------------------------------------
       
    95 //
       
    96 // CUAPrintingJob::SessionId
       
    97 //
       
    98 //--------------------------------------------------------------------------------------------
       
    99 TInt CUPPrintingJob::SessionId()
       
   100 {
       
   101 	return iSessionId;
       
   102 }
       
   103 
       
   104 
       
   105 
       
   106 //--------------------------------------------------------------------------------------------
       
   107 //
       
   108 // CUPPrintingJob::SetJobId
       
   109 //
       
   110 //--------------------------------------------------------------------------------------------
       
   111 void CUPPrintingJob::SetJobId(const TDesC8& aId)
       
   112 {
       
   113 	iJobId.Copy(aId);
       
   114 	iJobState->SetActiveId(aId);
       
   115 	// SetActiveId initializes iJobState -> set sheets to print
       
   116 	iJobState->SetSheetsToPrint(Sheets());
       
   117 
       
   118 	LOG1("[CUPPrintingJob::SetJobId]\t Sheets(). %d", Sheets());
       
   119 	
       
   120 }
       
   121 
       
   122 
       
   123 //--------------------------------------------------------------------------------------------
       
   124 //
       
   125 // CUPPrintingJob::GetJobId
       
   126 //
       
   127 //--------------------------------------------------------------------------------------------
       
   128 void CUPPrintingJob::GetJobId(TDes8& aId)
       
   129 {
       
   130 	aId.Copy(iJobId);
       
   131 }
       
   132 
       
   133 
       
   134 //--------------------------------------------------------------------------------------------
       
   135 //
       
   136 // CUPPrintingJob::GetJobName
       
   137 //
       
   138 //--------------------------------------------------------------------------------------------
       
   139 void CUPPrintingJob::GetJobName(TDes8& aJobName)
       
   140 {
       
   141 	// Return the name of first image
       
   142 	if (iImages.Count() > 0)
       
   143 	{
       
   144 		iImages[0].GetFilePath(aJobName);
       
   145 	}
       
   146 	else
       
   147 	{
       
   148 		aJobName.Append(KNullDesC8());
       
   149 	}
       
   150 }
       
   151 
       
   152 //--------------------------------------------------------------------------------------------
       
   153 //
       
   154 // CUPPrintingJob::ImageCount
       
   155 //
       
   156 //--------------------------------------------------------------------------------------------
       
   157 TInt CUPPrintingJob::ImageCount()
       
   158 {
       
   159 	return iImages.Count();
       
   160 }
       
   161 
       
   162 //--------------------------------------------------------------------------------------------
       
   163 //
       
   164 // CUPPrintingJob::Images
       
   165 //
       
   166 //--------------------------------------------------------------------------------------------
       
   167 void CUPPrintingJob::Images(RArray<CImageInfo>& aImages)
       
   168 {
       
   169 	for (TInt i=0; i < iImages.Count(); i++)
       
   170 	{
       
   171 		aImages.Append(iImages[i]);
       
   172 	}
       
   173 }
       
   174 
       
   175 
       
   176 //--------------------------------------------------------------------------------------------
       
   177 //
       
   178 // CUPPrintingJob::PrinterId
       
   179 //
       
   180 //--------------------------------------------------------------------------------------------
       
   181 TInt CUPPrintingJob::PrinterId()
       
   182 {
       
   183 	return iPrinterId;
       
   184 }
       
   185 
       
   186 //--------------------------------------------------------------------------------------------
       
   187 //
       
   188 // CUPPrintingJob::GetUserName
       
   189 //
       
   190 //--------------------------------------------------------------------------------------------
       
   191 void CUPPrintingJob::GetUserName(TPtrC8& aUserName)
       
   192 {
       
   193 	aUserName.Set(iUserName);
       
   194 }
       
   195 
       
   196 //--------------------------------------------------------------------------------------------
       
   197 //
       
   198 // CUPPrintingJob::ShareFileL
       
   199 //
       
   200 //--------------------------------------------------------------------------------------------
       
   201 void CUPPrintingJob::ShareFileL(CUpnpItem* aItemToShare) 
       
   202 {
       
   203 	User::LeaveIfNull(aItemToShare);
       
   204 
       
   205 	LOG81("[CUPPrintingJob::ShareFileL]\t ShareFileL: %S", &(aItemToShare->RefId()));
       
   206 
       
   207 	TRAPD( err, iFileSharing->ShareItemL(*aItemToShare));
       
   208 	
       
   209 	if (KErrAlreadyExists == err)
       
   210 	{
       
   211 		// Resolve http address of the already shared file
       
   212 		TLex8 tmp(aItemToShare->Id());
       
   213 		TInt tmpId;
       
   214 		tmp.Val(tmpId);
       
   215 
       
   216 		iFileSharing->GetSharedItemL(tmpId, *aItemToShare);
       
   217 
       
   218 	}
       
   219 	else if(err == KErrNotFound)
       
   220 	{
       
   221 		LOG("[CUPPrintingJob]\t - ShareItemL: file not found");
       
   222 		User::Leave(EPbFileNotFound);
       
   223 	}
       
   224 	else if(err != KErrNone)
       
   225 	{
       
   226 		LOG1("[CUPPrintingJob]\t - ShareItemL: %d", err);
       
   227 		User::Leave(err);
       
   228 	}
       
   229 }
       
   230 
       
   231 //--------------------------------------------------------------------------------------------
       
   232 //
       
   233 // CUPPrintingJob::ShareImagesL
       
   234 //
       
   235 //--------------------------------------------------------------------------------------------
       
   236 void CUPPrintingJob::ShareImagesL()
       
   237 {
       
   238 	LOG("[CUPPrintingJob]\t ShareImagesL");
       
   239 	TBuf8<1024> tmpUri;
       
   240 	for (TInt i=0; i<iImages.Count(); i++)
       
   241 	{
       
   242 		// Skip images with no file path (they are already shared by external repository)
       
   243 		TFileName8 name;
       
   244 		iImages[i].GetFilePath(name);
       
   245 		if (name.Length() < 1)
       
   246 		{
       
   247 			continue;
       
   248 		}
       
   249 
       
   250 		// Generate id
       
   251 		TInt itemId = KUPnPIdBase+i;	
       
   252 	  LOG("[CUPPrintingJob::ConstructL]\t File sharing opened");
       
   253 		CUpnpItem* upnpItem = UPnPItemLC(itemId, name, KImageType, KJpegMime);
       
   254 
       
   255 		ShareFileL(upnpItem);
       
   256 		
       
   257 		// Get "res"-element value after filesharing.
       
   258 		RUPnPElementsArray tmpElementArray;
       
   259 		tmpElementArray = upnpItem->GetElements();
       
   260 		for(TInt j = 0; j<tmpElementArray.Count();j++)
       
   261 			if(tmpElementArray[j]->Name() == KResource)
       
   262 				tmpUri.Copy(tmpElementArray[j]->Value());
       
   263 
       
   264 		// Parse shared folder address in the "res"-element value.
       
   265 		TFileName8 itemAddress;		
       
   266 		TBuf8<1024> tmpPartOfUri;
       
   267 		tmpPartOfUri.Copy( tmpUri.Mid(28));
       
   268 		itemAddress.Copy(iMediaServerAddress);
       
   269 		itemAddress.Append(tmpPartOfUri); 
       
   270 
       
   271 		
       
   272 		// Set http address and id to image information
       
   273 		iImages[i].SetUri(itemAddress, ETrue);
       
   274 		LOG82("[CPrintJob::ShareImagesL]\t iFilePath: \"%S\", iUri: \"%S\"", &name, &itemAddress);
       
   275 		
       
   276 		TPtrC8 tmp = upnpItem->Id();
       
   277 		TLex8 lex( tmp );
       
   278 		TInt id;
       
   279 		lex.Val( id );
       
   280 		iImages[i].SetId(id);
       
   281 		
       
   282 		CleanupStack::PopAndDestroy( upnpItem );
       
   283 
       
   284 	}
       
   285 }
       
   286 
       
   287 //--------------------------------------------------------------------------------------------
       
   288 //
       
   289 // CUPPrintingJob::UnShareImages
       
   290 //
       
   291 //--------------------------------------------------------------------------------------------
       
   292 TInt CUPPrintingJob::UnShareImages()
       
   293 {
       
   294 	LOG("[CUPPrintingJob]\t UnShareImages");
       
   295 	
       
   296 	for (TInt i=0; i < iImages.Count(); i++)
       
   297 	{
       
   298 		UnShareFile(iImages[i].Id());
       
   299 	}
       
   300 
       
   301 	return KErrNone;
       
   302 }
       
   303 
       
   304 //--------------------------------------------------------------------------------------------
       
   305 //
       
   306 // CUPPrintingJob::UnShareFile
       
   307 //
       
   308 //--------------------------------------------------------------------------------------------
       
   309 TInt CUPPrintingJob::UnShareFile(TInt aItemId)
       
   310 {
       
   311 	LOG("[CUPPrintingJob::UnShareFile]");
       
   312 
       
   313 	if (aItemId < 0)
       
   314 	{
       
   315 		// Not shared because no item id is set
       
   316 		return KErrNone;
       
   317 	}
       
   318 		
       
   319 	TBuf8<KMaxIdLength> itemIdStr;
       
   320 	itemIdStr.AppendNum(aItemId);
       
   321 	LOG1("[CUPPrintingJob::UnShareFile]\t Item id = %d", aItemId);
       
   322 
       
   323 	TRAPD(err, iFileSharing->UnshareItemL(aItemId));
       
   324 	LOG1("[CUPPrintingJob::UnShareFile]\t err = %d", err);
       
   325 	return err;
       
   326 }
       
   327 
       
   328 //--------------------------------------------------------------------------------------------
       
   329 //
       
   330 // CUPPrintingJob::SetNumsOfCopies
       
   331 //
       
   332 //--------------------------------------------------------------------------------------------
       
   333 TInt CUPPrintingJob::SetNumsOfCopies( const RArray<TInt>& aNumsOfCopies)
       
   334 {
       
   335 	TInt err = KErrNone;
       
   336 	
       
   337 	for(TInt arrayIx = 0, imgIx = 0; arrayIx < aNumsOfCopies.Count(); ++arrayIx)
       
   338 	{
       
   339 		if(iImages[imgIx].Index() < aNumsOfCopies.Count())
       
   340 		{
       
   341 			TInt copies = aNumsOfCopies[iImages[imgIx].Index()];
       
   342 			if(0 < copies)
       
   343 				iImages[imgIx].SetCopies(copies);
       
   344 			++imgIx;
       
   345 		}
       
   346 		else
       
   347 			err = KErrCorrupt;
       
   348 	}
       
   349 	return err;
       
   350 }
       
   351 
       
   352 //--------------------------------------------------------------------------------------------
       
   353 //
       
   354 // CUPPrintingJob::GetPrintFileL
       
   355 //
       
   356 //--------------------------------------------------------------------------------------------
       
   357 void CUPPrintingJob::GetPrintFileL(TDes8& aPrintFile)
       
   358 {
       
   359 	TInt layout;
       
   360 	TInt paper;
       
   361 	TInt quality;
       
   362 	TBuf8<1024> tmpUri;
       
   363 	
       
   364 	iPrintFactory->GetPrintSetting(EPrintCapabLayout, layout);
       
   365 	iPrintFactory->GetPrintSetting(EPrintCapabPaperSize, paper);
       
   366 	iPrintFactory->GetPrintSetting(EPrintCapabQuality, quality);
       
   367 
       
   368 	TFileName tmpFile;
       
   369 	tmpFile.Copy(aPrintFile);
       
   370 	iPrintFactory->CreateXhtmlFileL( iImages, layout, paper, quality, tmpFile, iSheets );
       
   371 	aPrintFile.Copy(tmpFile);
       
   372 }
       
   373 
       
   374 
       
   375 //--------------------------------------------------------------------------------------------
       
   376 //
       
   377 // CUPPrintingJob::Sheets
       
   378 //
       
   379 //--------------------------------------------------------------------------------------------
       
   380 TInt CUPPrintingJob::Sheets()
       
   381 {
       
   382 	if(0 == iSheets)
       
   383 	{
       
   384 		TInt layout;
       
   385 		TInt layoutNbr = 0;
       
   386 		TInt imageNbr = 0;
       
   387 		
       
   388 		iPrintFactory->GetPrintSetting(EPrintCapabLayout, layout);
       
   389 
       
   390 		switch( layout )
       
   391 		{
       
   392 			case EPrintCapabLayout1Up:
       
   393 			case EPrintCapabLayout1UpBorderless:
       
   394 			case EPrintCapabLayout1UpBorder:
       
   395 				layoutNbr = 1;
       
   396 				break;
       
   397 			case EPrintCapabLayout2Up:
       
   398 				layoutNbr = 2;
       
   399 				break;
       
   400 			case EPrintCapabLayout4Up:
       
   401 				layoutNbr = 4;
       
   402 				break;
       
   403 			case EPrintCapabLayout6Up:
       
   404 				layoutNbr = 6;
       
   405 				break;
       
   406 			case EPrintCapabLayout9Up:
       
   407 				layoutNbr = 9;
       
   408 				break;
       
   409 			case EPrintCapabLayout12Up:
       
   410 				layoutNbr = 12;
       
   411 				break;
       
   412 			case EPrintCapabLayout16Up:
       
   413 				layoutNbr = 16;
       
   414 				break;
       
   415 			default:
       
   416 				break;
       
   417 		}
       
   418 
       
   419 		for (TInt i = 0; i<iImages.Count(); ++i)
       
   420 		{
       
   421 			imageNbr += iImages[i].Copies();
       
   422 		}
       
   423 		
       
   424 		iSheets = imageNbr / layoutNbr;	
       
   425 		if(0 < imageNbr % layoutNbr)
       
   426 			++iSheets;
       
   427 	}
       
   428 	LOG1("[CUPPrintingJob::Sheets]\t iSheets = %d", iSheets);
       
   429 	return iSheets;
       
   430 }
       
   431 
       
   432 //--------------------------------------------------------------------------------------------
       
   433 //
       
   434 // CUPPrintingJob::Progress
       
   435 //
       
   436 //--------------------------------------------------------------------------------------------
       
   437 TInt CUPPrintingJob::Progress()
       
   438 {
       
   439 	return iJobState->Progress(Sheets());
       
   440 }
       
   441 
       
   442 
       
   443 // Protected functions
       
   444 //--------------------------------------------------------------------------------------------
       
   445 //
       
   446 // CUPPrintingJob::ConstructL
       
   447 //
       
   448 //--------------------------------------------------------------------------------------------
       
   449 void CUPPrintingJob::ConstructL(CUPPrinter* aPrinter, RArray<TFileName>& aImages, const TDesC8& aUserName)
       
   450 {
       
   451 	_LIT(KHttpPrefixLow16, "http://");
       
   452 	
       
   453 	if (aImages.Count() < 1)
       
   454 	{
       
   455 		User::Leave(KErrArgument);
       
   456 	}
       
   457 	
       
   458 	// Initialize iImages array
       
   459 	for (TInt i=0 ; i<aImages.Count(); i++)
       
   460 	{
       
   461 		// Skip empty strings
       
   462 		if (aImages[i].Length() < 1)
       
   463 		{
       
   464 			continue;
       
   465 		}
       
   466 		
       
   467 		aImages[i].LowerCase();
       
   468 
       
   469 		CImageInfo *imageInfo = CImageInfo::NewLC();
       
   470 				
       
   471 		imageInfo->SetId(KErrNotFound);
       
   472 		imageInfo->SetIndex(i);
       
   473 		imageInfo->SetCopies(1);	
       
   474 		
       
   475 		if (aImages[i].Compare(KHttpPrefixLow16()) < 0 )
       
   476 		{
       
   477 			// Images with file path
       
   478 			imageInfo->SetFilePathL(aImages[i]);
       
   479 		}
       
   480 		else
       
   481 		{
       
   482 			// Images with HTTP address	
       
   483 			imageInfo->SetUriL(aImages[i]);
       
   484 		}
       
   485 		iImages.Append( *imageInfo );
       
   486 		CleanupStack::PopAndDestroy( imageInfo );
       
   487 	}	
       
   488 	
       
   489 	// Set printer 
       
   490 	iPrinterId = aPrinter->Id();
       
   491 	
       
   492 	iUserName.Set(aUserName);
       
   493 	iJobState = CUPJobState::NewL();
       
   494 	iSheets = 0;
       
   495 	
       
   496 	iFileSharing = CUPFileSharingActive::NewL();
       
   497 	
       
   498   // Connect to the local media server and open file sharing session
       
   499   LOG("[CUPPrintingJob::ConstructL]\t Media server connected");
       
   500   User::LeaveIfError(iMediaServerClient.Connect());
       
   501   
       
   502   // get original MS status and start MS if needed. 
       
   503   // If MS is in wrong status(started offline mode) then stop MS and start it in online-mode.
       
   504   iMediaServerClient.Status(iOrgMediaServerStatus);
       
   505   if(iOrgMediaServerStatus != RUpnpMediaServerClient::EStartedOnline)
       
   506   {
       
   507   	if(iOrgMediaServerStatus == RUpnpMediaServerClient::EStartedOffline)
       
   508   	{
       
   509   	  iMediaServerClient.Stop();
       
   510   	}
       
   511   	CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();                        
       
   512 	TBuf8<1024> media;    
       
   513  
       
   514 	//// Supported Media                                             
       
   515 	media.Copy(KMediaTypes);
       
   516 	settings->SetL(UpnpMediaServerSettings::ESupportedMedia, media);
       
   517 	delete settings;
       
   518   	LOG("[CUPPrintingJob::ConstructL]\t Media server start");
       
   519     User::LeaveIfError(iMediaServerClient.Start());
       
   520   }
       
   521   
       
   522   // Get Media server ip address and port number.
       
   523 	TFileName8 tmpAddress;
       
   524 	TInetAddr timppi;
       
   525 	TInt err = iMediaServerClient.GetAddress(timppi);
       
   526 	
       
   527 	TFileName addr16;
       
   528 	timppi.Output(addr16);
       
   529 
       
   530 	// Address
       
   531 	iMediaServerAddress.Copy( KHttpPrefix() );
       
   532 	iMediaServerAddress.Append(addr16);
       
   533 
       
   534 	// Port
       
   535 	iMediaServerAddress.Append( KUPnPColon() );
       
   536 	iMediaServerAddress.AppendNum(timppi.Port());
       
   537 }
       
   538 
       
   539 
       
   540 // Private functions
       
   541 //--------------------------------------------------------------------------------------------
       
   542 //
       
   543 // CUPPrintingJob::CUPPrintingJob
       
   544 //
       
   545 //--------------------------------------------------------------------------------------------
       
   546 CUPPrintingJob::CUPPrintingJob(CUPPrintFactory* aFileFactory) : 
       
   547 iSessionId(KErrNotFound),
       
   548 iPrintFactory(aFileFactory),
       
   549 iXhtmlFileShareId(0)
       
   550 {
       
   551 }
       
   552 
       
   553 //--------------------------------------------------------------------------------------------
       
   554 //
       
   555 // CUPPrintingJob::UPnPItem
       
   556 //
       
   557 //--------------------------------------------------------------------------------------------
       
   558 CUpnpItem* CUPPrintingJob::UPnPItemLC(TInt aItemId, const TDesC8& aFileName, const TDesC8& aObjectType, const TDesC8& aMimeType)
       
   559 {
       
   560 	// Init upnp item
       
   561 	CUpnpItem* upnpItem = CUpnpItem::NewL();
       
   562 	CleanupStack::PushL(upnpItem);
       
   563 
       
   564 	upnpItem->SetRefIdL(aFileName);
       
   565 	TFileName8 tmpTitle;
       
   566 	TInt tmpLocate = aFileName.LocateReverse( TChar( '\\' ) );
       
   567 	tmpLocate++;
       
   568 	tmpTitle.Copy(aFileName.Mid(tmpLocate));
       
   569 	upnpItem->SetTitleL(tmpTitle);
       
   570 	upnpItem->SetObjectClassL(aObjectType);
       
   571 
       
   572 	TBuf8<KMaxIdLength> itemIdStr;
       
   573 	itemIdStr.AppendNum(aItemId);
       
   574 	upnpItem->SetIdL(itemIdStr);
       
   575 	upnpItem->SetRestricted(0);
       
   576 	_LIT8(KDefParentId, "0");
       
   577 	upnpItem->SetParentIdL(KDefParentId);
       
   578 
       
   579 	// Convert FileName to the unicode that MediaServer can handle it correct.
       
   580 	HBufC16* buf = EscapeUtils::ConvertToUnicodeFromUtf8L(aFileName);
       
   581 	CleanupStack::PushL(buf);
       
   582   
       
   583 	CUpnpProtocolInfo* protocolInfo = CUpnpProtocolInfo::NewL();
       
   584   CleanupStack::PushL(protocolInfo);
       
   585   protocolInfo->SetFirstFieldL(_L8("http-get"));
       
   586   protocolInfo->SetSecondFieldL(_L8("*"));
       
   587   protocolInfo->SetThirdFieldL(aMimeType);
       
   588   protocolInfo->SetFourthFieldL(_L8("*"));
       
   589   
       
   590   upnpItem->AddResourceL(buf->Des(), protocolInfo->ProtocolInfoL());
       
   591   CleanupStack::Pop(protocolInfo);
       
   592  	CleanupStack::PopAndDestroy(buf);
       
   593 
       
   594 	return upnpItem;
       
   595 }
       
   596 
       
   597 //--------------------------------------------------------------------------------------------
       
   598 //
       
   599 // CUPPrintingJob::UpdateJobState
       
   600 //
       
   601 //--------------------------------------------------------------------------------------------
       
   602 TUPnPState CUPPrintingJob::UpdateJobState(const TDesC8& aPrinterState, const TDesC8& aReason, const TDesC8& aJobList, const TDesC8& aJobId, const TDesC8& aJobMediaSheetsCompleted)
       
   603 {
       
   604 //	LOG("[CUPPrintingJob::UpdateJobState]\t");
       
   605 
       
   606 	return iJobState->UpdateJobState(aPrinterState, aReason, aJobList, aJobId, aJobMediaSheetsCompleted);
       
   607 }
       
   608 
       
   609 //--------------------------------------------------------------------------------------------
       
   610 //
       
   611 // CUPPrintingJob::JobStateReason
       
   612 //
       
   613 //--------------------------------------------------------------------------------------------
       
   614 TInt CUPPrintingJob::JobStateReason()
       
   615 {
       
   616 	return iJobState->Reason();
       
   617 }
       
   618 
       
   619 //--------------------------------------------------------------------------------------------
       
   620 //
       
   621 // CUPPrintingJob::JobState
       
   622 //
       
   623 //--------------------------------------------------------------------------------------------
       
   624 CUPJobState* CUPPrintingJob::JobState()
       
   625 {
       
   626 	return iJobState;
       
   627 }
       
   628 
       
   629 //--------------------------------------------------------------------------------------------
       
   630 //
       
   631 // CUPPrintingJob::PrinterStateUpdated
       
   632 //
       
   633 //--------------------------------------------------------------------------------------------
       
   634 TUPnPState CUPPrintingJob::PrinterStateUpdated( const TDesC8& aEvent )
       
   635 {
       
   636 	return iJobState->PrinterStateUpdated(aEvent);	
       
   637 }
       
   638 
       
   639 //--------------------------------------------------------------------------------------------
       
   640 //
       
   641 // CUPPrintingJob::PrinterStateReasonsUpdated
       
   642 //
       
   643 //--------------------------------------------------------------------------------------------
       
   644 TUPnPState CUPPrintingJob::PrinterStateReasonsUpdated( const TDesC8& aEvent )
       
   645 {
       
   646 	return iJobState->PrinterStateReasonsUpdated(aEvent);	
       
   647 }
       
   648 
       
   649 //--------------------------------------------------------------------------------------------
       
   650 //
       
   651 // CUPPrintingJob::JobIdListUpdated
       
   652 //
       
   653 //--------------------------------------------------------------------------------------------
       
   654 TUPnPState CUPPrintingJob::JobIdListUpdated( const TDesC8& aEvent )
       
   655 {
       
   656 	return iJobState->JobIdListUpdated(aEvent);	
       
   657 }
       
   658 
       
   659 //--------------------------------------------------------------------------------------------
       
   660 //
       
   661 // CUPPrintingJob::JobEndStateUpdatedL
       
   662 //
       
   663 //--------------------------------------------------------------------------------------------
       
   664 TUPnPState CUPPrintingJob::JobEndStateUpdatedL( const TDesC8& aEvent )
       
   665 {
       
   666 	return iJobState->JobEndStateUpdatedL(aEvent);	
       
   667 }
       
   668 
       
   669 //--------------------------------------------------------------------------------------------
       
   670 //
       
   671 // CUPPrintingJob::JobMediaSheetsCompletedUpdated
       
   672 //
       
   673 //--------------------------------------------------------------------------------------------
       
   674 TUPnPState CUPPrintingJob::JobMediaSheetsCompletedUpdated( const TDesC8& aEvent )
       
   675 {
       
   676 	return iJobState->JobMediaSheetsCompletedUpdated(aEvent);	
       
   677 }
       
   678 
       
   679 //--------------------------------------------------------------------------------------------
       
   680 //
       
   681 // CUPPrintingJob::JobMediaSheetsCompletedUpdated
       
   682 //
       
   683 //--------------------------------------------------------------------------------------------
       
   684 TUPnPState CUPPrintingJob::JobMediaSheetsCompletedUpdated(const TDesC8& aId, const TDesC8& aEvent )
       
   685 {
       
   686 	return iJobState->JobMediaSheetsCompletedUpdated(aId, aEvent);	
       
   687 }
       
   688 
       
   689 //--------------------------------------------------------------------------------------------
       
   690 //
       
   691 // CUPPrintingJob::JobAbortStateUpdatedL
       
   692 //
       
   693 //--------------------------------------------------------------------------------------------
       
   694 TUPnPState CUPPrintingJob::JobAbortStateUpdatedL( const TDesC8& aEvent )
       
   695 {
       
   696 	return iJobState->JobAbortStateUpdatedL(aEvent);	
       
   697 }
       
   698 
       
   699 //--------------------------------------------------------------------------------------------
       
   700 //
       
   701 // CUPPrintingJob::ContentCompleteListUpdated
       
   702 //
       
   703 //--------------------------------------------------------------------------------------------
       
   704 TUPnPState CUPPrintingJob::ContentCompleteListUpdated( const TDesC8& aEvent )
       
   705 {
       
   706 	return iJobState->ContentCompleteListUpdated(aEvent);	
       
   707 }
       
   708 
       
   709 //  End of File