First public contribution.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
24 _LIT(KPdrExtension,"*.PDR"); // must be capitalized
25 _LIT(KPdlExtension,".PDL"); // must be capitalized
26 _LIT(KUdlExtension,".UDL"); // must be capitalized
27 _LIT(KRscExtension,".RSC");
28 _LIT(KGdiPrintPanic,"GDI - PRINT");
30 _LIT(KGDIPanicDesc1, "GDI Pdr internal Panic %S, in file %S @ line %i");
31 _LIT(KGDIPanicDesc2, "Assert condition = \"%S\"");
35 EPdrModelIndexOutOfRange,
37 EPdrDirectoryIndexOutOfRange,
38 EPdrFileIndexOutOfRange,
39 EPdrPrinterDeviceExists,
40 EPdrPrinterDeviceDoesNotExist,
43 void Panic(TPdrStorePanic aPanic)
45 User::Panic(KGdiPrintPanic,aPanic);
48 void PanicWithCondAndInfo(TPdrStorePanic aError, const TDesC& aCondition, const TDesC& aFileName, const TDesC& aPanicName, TInt aLine)
51 buf.Format(KGDIPanicDesc1, &aPanicName, &aFileName, aLine);
54 buf.Format(KGDIPanicDesc2, &aCondition);
64 EXPORT_C void TPrinterModelEntry::InternalizeL(RReadStream& aStream)
66 /** Internalises a printer model entry from a read stream.
68 The presence of this function means that the standard templated stream operator>>(),
69 defined in s32strm.h, is available to internalise objects of this class.
71 @param aStream The read stream. */
73 aStream >> iModelName;
74 iRequiresPrinterPort=aStream.ReadUint8L();
79 EXPORT_C void TPrinterModelEntry::ExternalizeL(RWriteStream& aStream) const
80 /** Externalises the printer model entry to a write stream.
82 The presence of this function means that the standard templated stream operator<<(),
83 defined in s32strm.h, is available to externalise objects of this class.
85 @param aStream The write stream. */
87 aStream << iModelName;
88 aStream.WriteUint8L((TUint8) iRequiresPrinterPort);
93 // TPrinterModelHeader
97 EXPORT_C void TPrinterModelHeader::InternalizeL(RReadStream& aStream)
98 /** Internalises a printer model header from a read stream.
100 The presence of this function means that the standard templated stream operator>>(),
101 defined in s32strm.h, is available to internalise objects of this class.
103 @param aStream The read stream. */
106 aStream >> iModelDataStreamId;
110 EXPORT_C void TPrinterModelHeader::ExternalizeL(RWriteStream& aStream) const
112 /** Externalises the printer model header to a write stream.
114 The presence of this function means that the standard templated stream operator<<(),
115 defined in s32strm.h, is available to externalise objects of this class.
116 @param aStream The write stream. */
119 aStream << iModelDataStreamId;
126 EXPORT_C CPrinterDevice::CPrinterDevice():
128 iCurrentPageSpecInTwips()
129 /** Standard constructor. */
133 EXPORT_C CPrinterDevice::~CPrinterDevice()
136 It frees all resources owned by the object, prior to its destruction. */
142 EXPORT_C void CPrinterDevice::SelectPageSpecInTwips(const TPageSpec& aPageSpecInTwips)
143 /** Sets the page specification in twips.
144 @param aPageSpec The page specification in twips. */
146 iCurrentPageSpecInTwips=aPageSpecInTwips;
150 EXPORT_C TRect CPrinterDevice::PrintablePageInPixels() const
151 /** Gets the dimensions of the area to which the printer device can print.
153 These dimensions are normally less than those returned by TPageSpec::OrientedPageSize()
154 because a margin exists between the boundary of the printable page and the
155 absolute extent of the page.
157 @return The dimensions of the printer device area in pixels, respecting the
160 return TRect(SizeInPixels());
164 EXPORT_C void CPrinterDevice::DeleteControl()
165 /** Deletes the printer control owned by this object.
167 The function sets the iControl member to NULL. */
174 EXPORT_C void CPrinterDevice::RestorePropertiesL()
175 /** Restores printer properties. */
177 _LIT(KSystemIniFileNameSpec,"Z:\\System\\System.ini");
180 User::LeaveIfError(fs.Connect());
181 CleanupClosePushL(fs);
183 TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));
184 TParse systemIniFileName;
185 systemIniFileName.Set(drive.Name(), &KSystemIniFileNameSpec, NULL);
188 TInt ret = fs.Att(systemIniFileName.FullName(), atts);
191 CDictionaryStore* dictionarystore = NULL;
192 TRAPD(err,dictionarystore = CDictionaryFileStore::SystemL(fs));
195 CleanupStack::PushL(dictionarystore);
196 if (dictionarystore->IsPresentL(Model().iUid))
198 RDictionaryReadStream stream;
199 stream.OpenLC(*dictionarystore,Model().iUid);
200 InternalizePropertiesL(stream);
201 CleanupStack::PopAndDestroy(); // stream
203 CleanupStack::PopAndDestroy(); // dictionarystore
206 CleanupStack::PopAndDestroy(); // fs
210 EXPORT_C void CPrinterDevice::StorePropertiesL() const
211 /** Stores the printer properties. */
214 User::LeaveIfError(fs.Connect());
215 CleanupClosePushL(fs);
216 CDictionaryStore* dictionarystore = CDictionaryFileStore::SystemLC(fs);
217 RDictionaryWriteStream stream;
218 stream.AssignLC(*dictionarystore,Model().iUid);
219 ExternalizePropertiesL(stream);
221 CleanupStack::PopAndDestroy(); // stream
222 dictionarystore->CommitL();
223 CleanupStack::PopAndDestroy(2); // dictionarystore, fs
231 EXPORT_C CPrinterControl::~CPrinterControl()
234 It frees all resources owned by the object, prior to its destruction. */
239 EXPORT_C CPrinterControl::CPrinterControl(CPrinterPort* aPrinterPort):
241 iState(ENotPrinting),
242 iPrinterPort(aPrinterPort)
250 EXPORT_C TPageSpec::TPageSpec():
251 iPortraitPageSize(TSize(0,0)),
252 iOrientation(EPortrait)
253 /** Default constructor.
255 Initialises the page orientation to portrait and the page height and width
260 EXPORT_C TPageSpec::TPageSpec(TPageOrientation anOrientation,const TSize& aSize):
261 iPortraitPageSize(aSize),
262 iOrientation(anOrientation)
263 /** Constructor with page orientation and size.
265 @param aOrientation Specifies the page orientation.
266 @param aSize Specifies the page size. */
270 EXPORT_C void TPageSpec::InternalizeL(RReadStream& aStream)
271 /** Internalises a page specification object from a read stream.
273 The presence of this function means that the standard templated stream operator>>(),
274 defined in s32strm.h, is available to internalise objects of this class.
276 @param aStream The read stream. */
278 iPortraitPageSize.iWidth = aStream.ReadInt32L();
279 iPortraitPageSize.iHeight = aStream.ReadInt32L();
280 iOrientation=(TPageSpec::TPageOrientation)aStream.ReadInt8L();
284 EXPORT_C void TPageSpec::ExternalizeL(RWriteStream& aStream) const
285 /** Externalises the page specification object to a write stream.
287 The presence of this function means that the standard templated stream operator<<(),
288 defined in s32strm.h, is available to externalise objects of this class.
289 @param aStream The write stream. */
291 aStream.WriteInt32L(iPortraitPageSize.iWidth);
292 aStream.WriteInt32L(iPortraitPageSize.iHeight);
293 aStream.WriteInt8L(iOrientation);
297 EXPORT_C TSize TPageSpec::OrientedPageSize()const
298 /** Gets the oriented page size.
300 The oriented page size is the absolute width and height of the page, respecting
301 the page orientation.
302 @return The oriented page size (in pixels or twips). */
304 if(iOrientation==EPortrait)
305 return(iPortraitPageSize);
306 return(TSize(iPortraitPageSize.iHeight,iPortraitPageSize.iWidth));
310 EXPORT_C TBool TPageSpec::operator==(const TPageSpec& aPageSpec) const
311 /** Equality operator.
313 This operator compares page specifications for equality. Two page specifications
314 are equal if both their orientations and portrait page sizes are equal.
316 @param aPageSpec Page specification to be compared.
317 @return ETrue, if the page specifications are equal; EFalse, otherwise. */
319 return(iPortraitPageSize==aPageSpec.iPortraitPageSize &&
320 iOrientation==aPageSpec.iOrientation);
324 EXPORT_C TBool TPageSpec::operator!=(const TPageSpec& aPageSpec) const
325 /** Inequality operator.
327 This operator compares two page specifications for inequality. Two page specifications
328 are unequal if one or both of their orientations and portrait page sizes differ.
330 @param aPageSpec Page specification to be compared.
331 @return ETrue, if the page specifications differ; EFalse, otherwise. */
333 return(!(*this==aPageSpec));
339 EXPORT_C void TMargins::InternalizeL(RReadStream& aStream)
340 /** Internalises a set of margins from a read stream.
342 The presence of this function means that the standard templated stream operator>>()
343 is available to internalise objects of this class.
345 @param aStream Stream from which the object is internalised. */
347 iLeft = aStream.ReadInt32L();
348 iRight = aStream.ReadInt32L();
349 iTop = aStream.ReadInt32L();
350 iBottom = aStream.ReadInt32L();
353 EXPORT_C void TMargins::ExternalizeL(RWriteStream& aStream) const
354 /** Externalises a set of margins to a write stream.
356 The presence of this function means that the standard templated stream operator<<()
357 is available to externalise objects of this class.
359 @param aStream Stream to which the object is externalised. */
361 aStream.WriteInt32L(iLeft);
362 aStream.WriteInt32L(iRight);
363 aStream.WriteInt32L(iTop);
364 aStream.WriteInt32L(iBottom);
367 EXPORT_C TBool TMargins::operator==(const TMargins& aMargins) const
368 /** Tests margins for equality.
370 @param aMargins The margin to be compared with this margin.
371 @return ETrue, if the margins are equal; EFalse, otherwise. */
373 return(iLeft==aMargins.iLeft && iRight==aMargins.iRight &&
374 iTop==aMargins.iTop && iBottom==aMargins.iBottom);
377 EXPORT_C TBool TMargins::operator!=(const TMargins& aMargins) const
378 /** Tests margins for inequality.
380 @param aMargins The margin to be compared with this margin.
381 @return ETrue, if the margins are unequal; EFalse, otherwise. */
383 return(!(*this==aMargins));
390 EXPORT_C CPrinterDriverUI::CPrinterDriverUI()
392 __DECLARE_NAME(_S("CPrinterDriverUI"));
396 EXPORT_C TBool CPrinterDriverUI::BeforePrintL()
397 /** Provides an opportunity for a dialog to be put up before printing begins.
399 @return ETrue, if printing is to continue; EFalse, if printing is to be cancelled.
400 The default implementation returns ETrue. */
406 EXPORT_C void CPrinterDriverUI::AfterPrintL()
407 /** Provides an opportunity for a dialog to be put up after printing is complete.
408 The default implementation is empty. */
413 EXPORT_C void CPrinterDriverUI::SetPropertiesL()
414 /** Provides an opportunity for a dialog to be put up to capture or change printer
416 The default implementation is empty. */
421 EXPORT_C TBool CPrinterDriverUI::CanSetProperties()
422 /** Tests whether printer properties can be set.
424 @return ETrue, if printer properties can be set; EFalse, otherwise. The default
425 implementation returns EFalse. */
435 EXPORT_C CPrinterDriver* CPrinterDriver::NewL()
436 /** Constructs, and returns a pointer to a new instance for accessing a printer
437 specification data store.
439 @return Pointer to the object for accessing a printer specification data store. */
441 CPrinterDriver* printerdriver=new(ELeave) CPrinterDriver;
442 CleanupStack::PushL(printerdriver);
443 User::LeaveIfError(printerdriver->iFs.Connect());
445 return printerdriver;
449 EXPORT_C CPrinterDriver::~CPrinterDriver()
452 It frees all resources owned by the object, prior to its destruction. In particular,
453 it closes the printer specification data store and any open session with the file server. */
460 EXPORT_C void CPrinterDriver::OpenPdrL(const TDesC &aName)
461 /** Opens the specified printer specification data store.
463 @return The name of the printer specification data store. This must be a
464 valid printer specification data store,otherwise the function leaves with
468 TRAPD(ret,DoOpenPdrL(aName));
476 EXPORT_C void CPrinterDriver::Close()
477 /** Closes the printer specification data store and frees resources.
479 An open session with the file server remains open. */
486 DeletePrinterDevice();
490 EXPORT_C TInt CPrinterDriver::NumModels() const
491 /** Gets the number of printer models defined by the printer specification.
493 @return The number of printer models. */
499 EXPORT_C TPrinterModelEntry CPrinterDriver::Model(TInt aNum) const
500 /** Gets the specified printer model.
502 @param aNum An index into the list of printer models defined in the printer
504 @return Model specific information. */
506 GDI_ASSERT_DEBUG(aNum>=0,EPdrModelIndexOutOfRange);
507 GDI_ASSERT_DEBUG(aNum<iNumModels,EPdrModelIndexOutOfRange);
508 return iModelList[aNum].iEntry;
512 EXPORT_C CPrinterDevice* CPrinterDriver::CreatePrinterDeviceL(TUid aModelUid)
513 /** Creates the physical graphics device to be used for printing.
515 @param aModelUid The UID of a specific model which is defined in the printer
517 @return The physical graphics device to be used for printing. */
519 GDI_ASSERT_DEBUG(!iPrinterDevice,EPdrPrinterDeviceExists);
520 TRAPD(ret,DoCreatePrinterDeviceL(aModelUid));
523 DeletePrinterDevice();
526 return iPrinterDevice;
529 void CPrinterDriver::LoadLibraryL(RLibrary& aLibrary,const TDesC& aExt,TUid aUid2)
531 TFileName filename=iPdlName;
532 filename.Append(aExt);
534 User::LeaveIfError(aLibrary.Load(filename));
535 TUidType type=aLibrary.Type();
536 if (type[1]!=aUid2 && type[2]!=iPdlUid)
539 User::Leave(KErrNotSupported);
544 User::Leave(KErrNotFound);
549 EXPORT_C CPrinterDriverUI* CPrinterDriver::CreatePrinterDriverUIL()
550 /** Constructs a printer specific user interface.
552 The user interface object is optional, but if it exists, it is implemented
553 as part of a UDL (i.e. a UI DLL).
555 @return A pointer to the printer specific user interface, or NULL if there is
558 GDI_ASSERT_DEBUG(iPrinterDevice,EPdrPrinterDeviceDoesNotExist);
559 if (iUdlLibrary.Handle()==0)
561 TRAPD(ret,LoadLibraryL(iUdlLibrary,KUdlExtension,TUid::Uid(KUdlUidVal)));
562 if (ret==KErrNotFound)
565 User::LeaveIfError(ret);
567 TLibraryFunction f = iUdlLibrary.Lookup(1);
568 CPrinterDriverUI* printerdriverui=(CPrinterDriverUI*)((*f)());
569 CleanupStack::PushL(printerdriverui);
570 User::LeaveIfError(printerdriverui->SetPrinterDevice(iPrinterDevice));
572 return printerdriverui;
575 CPrinterDriver::CPrinterDriver()
578 void CPrinterDriver::DeletePrinterDevice()
581 delete iPrinterDevice;
586 void CPrinterDriver::DoOpenPdrL(const TDesC &aName)
589 iPdrStore=CDirectFileStore::OpenL(iFs,aName,EFileStream|EFileRead|EFileShareReadersOnly);
590 if (iPdrStore->Type()[1]!=TUid::Uid(KPdrStoreFileUidVal))
591 User::Leave(KErrNotSupported);
592 TStreamId headerid = iPdrStore->Root();
593 RStoreReadStream stream;
594 stream.OpenLC(*iPdrStore,headerid);
597 iNumModels = stream.ReadInt32L();
598 iModelList = new(ELeave) TPrinterModelHeader[iNumModels];
599 for (TInt i=0; i<iNumModels; i++)
600 iModelList[i].InternalizeL(stream);
601 CleanupStack::PopAndDestroy();
604 void CPrinterDriver::DoCreatePrinterDeviceL(TUid aModelUid)
606 if (!iPdlName.Length())
607 User::Leave(KErrGeneral); // !! find a better error number
608 LoadLibraryL(iPdlLibrary,KPdlExtension,TUid::Uid(KPdlUidVal));
609 TLibraryFunction f = iPdlLibrary.Lookup(1);
610 iPrinterDevice=(CPrinterDevice*)((*f)());
612 for (i=0; (i<iNumModels) && (aModelUid!=iModelList[i].iEntry.iUid); i++)
615 GDI_ASSERT_DEBUG(i<iNumModels,EPdrModelUidNotFound);
616 User::LeaveIfError(iPrinterDevice->SetModel(iModelList[i],*iPdrStore));
617 iPrinterDevice->RestorePropertiesL();
625 EXPORT_C CPdrModelList* CPdrModelList::NewL()
626 /** Constructs, and returns a pointer to a new instance of the printer model
628 @return Pointer to the new printer model list interface object. */
630 CPdrModelList* modellist=new(ELeave) CPdrModelList();
631 CleanupStack::PushL(modellist);
632 modellist->ConstructL();
638 EXPORT_C CPdrModelList::~CPdrModelList()
639 /** Virtual destructor.
640 Frees resources owned by the object, prior to its destruction. */
645 {// delete all the HBufC's
646 for (TInt i=iDirectoryArray->Count()-1 ; i>=0 ; i--)
647 delete (*iDirectoryArray)[i];
648 delete iDirectoryArray;
654 EXPORT_C TInt CPdrModelList::ModelCount() const
655 /** Gets the number of printer models in the printer model list.
656 @return The number of printer models. */
658 return iModelArray->Count();
662 EXPORT_C const TPrinterModelEntry CPdrModelList::operator [] (TInt anIndex)
663 /** Gets printer model name.
665 This is the name of the printer model at the specified index within the list
668 @param anIndex The index of the printer model within the array of printer
669 models. Note that this number must be between zero and ModelCount().
671 @return Name of printer model, up to 32 characters long */
673 GDI_ASSERT_DEBUG(anIndex>=0,EPdrModelIndexOutOfRange);
674 GDI_ASSERT_DEBUG(anIndex<iModelArray->Count(),EPdrModelIndexOutOfRange);
676 return (*iModelArray)[anIndex].iEntry;
680 EXPORT_C TInt CPdrModelList::UidToNum(TUid aModelUid) const
681 /** Gets a printer model's index within the model list from its UID.
683 @param aModelUid The UID of the printer model.
684 @return The index of the printer model within the array of printer models if
685 found; KErrNotFound, otherwise. */
687 TInt i,count=iModelArray->Count();
688 for (i=0; (i<count) && (aModelUid!=(*iModelArray)[i].iEntry.iUid); i++)
699 EXPORT_C void CPdrModelList::AddDirectoryL(const TDesC& aDir)
700 /** Adds a directory to the list of directories to be scanned for printer models.
702 @param aDir The directory to be added to the list. */
704 HBufC* buf = HBufC::NewL(aDir.Length());
705 CleanupStack::PushL(buf);
707 iDirectoryArray->AppendL(buf);
708 CleanupStack::Pop(); //buf
711 LOCAL_C void DereferenceAndDeleteHBufC8(TAny* aPointerToPointerToHBufC8)
713 delete *STATIC_CAST(HBufC8**, aPointerToPointerToHBufC8);
717 EXPORT_C CPrinterModelList* CPdrModelList::ScanForModelsL()
718 /** Scans through through the list of directories for all .pdr files and generates
719 a list of printer models.
721 @return The list of model names. */
723 iModelArray->Reset();
725 // check that there is at least one directory to parse?
726 // get a list of *.pdr files in all directories specified (using AddDirectory())
727 for (TInt index=iDirectoryArray->Count()-1 ; index>=0 ; index--)
728 ScanDirectoryL(index);
729 // then go through the files one at a time, adding all models to the list
730 TParse* parser = new(ELeave) TParse;
731 CleanupStack::PushL(parser);
732 TFileName* nameOfLoadedResourceFile=new(ELeave) TFileName;
733 CleanupStack::PushL(nameOfLoadedResourceFile);
734 TFileName* tempFileName=new(ELeave) TFileName;
735 CleanupStack::PushL(tempFileName);
736 RResourceFile resourceFile;
737 CleanupClosePushL(resourceFile);
738 HBufC8* resource=NULL;
739 CleanupStack::PushL(TCleanupItem(DereferenceAndDeleteHBufC8, &resource));
740 for (TInt fileNum=iFileArray->Count()-1 ; fileNum>=0 ; fileNum--)
741 ListModelsL(fileNum, *parser, *nameOfLoadedResourceFile, *tempFileName, resourceFile, resource);
742 CleanupStack::PopAndDestroy(5); // resource, resourceFile, tempFileName, nameOfLoadedResourceFile and parser
743 // return a handle to the array of model names
748 EXPORT_C CPrinterDriver* CPdrModelList::CreatePrinterDriverL(TInt anIndex)
749 /** Creates an object for accessing the specified store that contains printer specification
752 @param anIndex An index into a list of files containing printer specification
753 data. The files are the complete set of .pdr files found in the directories
754 known to this object.
755 @return A pointer to the object representing the store containing the printer
756 specification data. */
758 GDI_ASSERT_DEBUG(anIndex>=0,EPdrModelIndexOutOfRange);
759 GDI_ASSERT_DEBUG(anIndex<iModelArray->Count(),EPdrModelIndexOutOfRange);
761 CPrinterDriver* driver = CPrinterDriver::NewL();
762 CleanupStack::PushL(driver);
763 HBufC* file = NewPathBufL(*((*iModelArray)[anIndex].iFile));
764 CleanupStack::PushL(file);
765 driver->OpenPdrL(*file);
766 driver->CreatePrinterDeviceL((*iModelArray)[anIndex].iEntry.iUid);
767 CleanupStack::PopAndDestroy();
773 CPdrModelList::CPdrModelList():
776 iDirectoryArray(NULL)
780 void CPdrModelList::ConstructL()
782 __DECLARE_NAME(_S("CPdrModelList"));
783 iModelArray = new(ELeave) CArrayFixSeg<TModelEntry>(5);
784 iFileArray = new(ELeave) CArrayFixFlat<TFileEntry>(5);
785 iDirectoryArray = new(ELeave) CArrayFixFlat<HBufC*>(1);
786 User::LeaveIfError(iFileServer.Connect());
789 void CPdrModelList::ScanDirectoryL(TInt aDirIndex)
790 /** Scans the given directory, parsing all files found
791 If a file is of the correct type it is appended to the file list*/
793 GDI_ASSERT_DEBUG(aDirIndex>=0,EPdrDirectoryIndexOutOfRange);
794 GDI_ASSERT_DEBUG(aDirIndex<iDirectoryArray->Count(),EPdrDirectoryIndexOutOfRange);
796 TDesC* dir = (*iDirectoryArray)[aDirIndex];
798 path.Set(KPdrExtension,dir,NULL);
800 TInt ret = iFileServer.GetDir(path.FullName(),KEntryAttNormal,ESortByName,fileList);
803 CleanupStack::PushL(fileList);
804 for (TInt i=fileList->Count()-1 ; i>=0 ; i--)
806 TFileEntry& entry = iFileArray->ExtendL();
807 entry.iFileName = (*fileList)[i].iName;
808 entry.iDirectory = dir;
810 CleanupStack::PopAndDestroy(); // fileList
812 else if (ret == KErrNoMemory) // Ignore errors other than KErrNoMemory
813 User::LeaveNoMemory();
816 void CPdrModelList::ListModelsL(TInt aFileIndex, TParse& aParser, TFileName& aNameOfLoadedResourceFile, TFileName& aTempFileName, RResourceFile& aResourceFile, HBufC8*& aResource)
817 /** given a pdr file list all the models it contains in the model array */
819 GDI_ASSERT_DEBUG(aFileIndex>=0,EPdrFileIndexOutOfRange);
820 GDI_ASSERT_DEBUG(aFileIndex<iFileArray->Count(),EPdrFileIndexOutOfRange);
822 CPrinterDriver* driver = CPrinterDriver::NewL() ;
823 CleanupStack::PushL(driver);
825 HBufC* fullPath = NewPathBufL((*iFileArray)[aFileIndex]);
826 TRAPD(ret,driver->OpenPdrL(*fullPath));
828 if ((ret!=KErrNone) && (ret!=KErrNotSupported))
830 // get info on the models one by one and insert them into the array
833 TModelEntry modelentry;
834 modelentry.iFile = &(*iFileArray)[aFileIndex]; // set the file pointer for the entry
835 const TInt numberOfModels = driver->NumModels();
836 for (TInt i=0 ; i<numberOfModels ; i++)
838 modelentry.iEntry=driver->Model(i);
839 if (UidToNum(modelentry.iEntry.iUid)==KErrNotFound)
841 User::LeaveIfError(aParser.SetNoWild(KRscExtension, &modelentry.iFile->iFileName, modelentry.iFile->iDirectory));
842 aTempFileName=aParser.FullName();
843 BaflUtils::NearestLanguageFile(iFileServer, aTempFileName);
844 if (aNameOfLoadedResourceFile.CompareF(aTempFileName)!=0)
846 if (!BaflUtils::FileExists(iFileServer, aTempFileName))
848 iModelArray->AppendL(modelentry); // no resource file found, so reverting to old behaviour (i.e. where the model-name is set from the PDR file)
851 aNameOfLoadedResourceFile=KNullDesC;
852 aResourceFile.OpenL(iFileServer, aTempFileName);
853 HBufC8* resource=aResourceFile.AllocReadL(aResourceFile.Offset()+2); // read the first resource after the RSS_SIGNATURE resource
856 aNameOfLoadedResourceFile=aTempFileName;
858 TResourceReader resourceReader;
859 resourceReader.SetBuffer(aResource);
860 for (TInt j=resourceReader.ReadUint16()-1; ; --j)
864 iModelArray->AppendL(modelentry); // no matching uid found in the resource file, so reverting to old behaviour (i.e. where the model-name is set from the PDR file)
867 TInt uid=resourceReader.ReadInt32();
868 TPtrC name=resourceReader.ReadTPtrC();
869 if (uid==modelentry.iEntry.iUid.iUid)
873 modelentry.iEntry.iModelName=name;
874 iModelArray->AppendL(modelentry);
882 CleanupStack::PopAndDestroy(); // driver
886 HBufC* CPdrModelList::NewPathBufL(const TFileEntry& aFileEntry)
887 /** Create a buf of the right length and...
888 set its contents to the full filename of model aModel */
890 // Create a buf of the right length
891 HBufC* buf = HBufC::NewL(aFileEntry.iFileName.Length()+aFileEntry.iDirectory->Length());
892 // Insert the file path
893 TPtr filePtr = buf->Des();
894 filePtr.Append(*aFileEntry.iDirectory);
895 filePtr.Append(aFileEntry.iFileName);
900 // Retained for binary compatibility only: remove if we make a binary incompatible release
903 IMPORT_C void GDI_Reserved();
904 EXPORT_C void GDI_Reserved()