home *** CD-ROM | disk | FTP | other *** search
- // PDFFileRecognizer.cpp
- //
- // Recognise pdf files (EPOC R3)
- //
- // Copyright (c) 2000 Sander van der Wal
- //
- // $Id: Pdffilerecognizer.cpp 1.2 2000-09-21 14:07:00+02 svdwal Exp svdwal $
- //
- // $Log: Pdffilerecognizer.cpp $
- // Revision 1.2 2000-09-21 14:07:00+02 svdwal
- // Some small changes
- //
- // Revision 1.1 2000-09-17 15:11:31+02 svdwal
- // Initial checkin
- //
-
- #include "PDFFileRecognizer.h"
-
- #ifndef __E32SVR_H__
- #include <e32svr.h>
- #endif
- #ifndef __S32FILE_H__
- #include <s32file.h>
- #endif
- #ifndef __F32FILE_H__
- #include <f32file.h>
- #endif
-
- // -- APPARC
- #ifndef __APAID_H__
- #include <apaid.h>
- #endif
- #ifndef __APACMDLN_H__
- #include <apacmdln.h>
- #endif
- #ifndef __APGCLI_H__
- #include <apgcli.h>
- #endif
-
-
- const TInt KPDFViewerUidValue = 0x10005D2C;
- const TUid KUidPDFViewer={KPDFViewerUidValue};
-
- // Recognises PDF files - by examining the file's contents
- CApaFileRecognizerType::TRecognizedType CPDFFileRecognizer::DoRecognizeFileL(RFs& aFs, TUidType /*aType*/)
- {
- iRecognizedType=ENotRecognized;
- //Pdf files are only recognized by contet, not by extension!
-
- RFile file;
- if (file.Open(aFs, *iFullFileName, EFileShareReadersOnly)!=KErrNone)
- return iRecognizedType;
- TBuf8<1024> buf; // keep in step with pdf/Stream.cpp
- TInt err = file.Read(buf);
- file.Close();
- if (err!=KErrNone)
- return iRecognizedType;
- if (buf.FindF(_L("%PDF-"))!=KErrNotFound) {
- iRecognizedType=EDoc;
- iAppUid=KUidPDFViewer;
- return iRecognizedType;
- }
- return iRecognizedType;
- }
-
- TThreadId CPDFFileRecognizer::RunL(TApaCommand aCommand,const TDesC* aDocFileName,const TDesC* aTailEnd) const
- {
- CApaCommandLine* commandLine=CApaCommandLine::NewLC();
- commandLine->SetCommandL(aCommand);
- if (iRecognizedType==EDoc) {
- // We've recognised a doc so we need to scan for its associated app
- TApaAppEntry appEntry;
- User::LeaveIfError(iFileRecognizer->AppLocator()->GetAppEntryByUid(appEntry,iAppUid));
- commandLine->SetLibraryNameL(appEntry.iFullName);
- if (aDocFileName)
- commandLine->SetDocumentNameL(*iFullFileName);
- }
- else {
- User::Leave(KErrNotSupported);
- }
- if (aTailEnd)
- commandLine->SetTailEndL(*aTailEnd);
- TThreadId id=AppRunL(*commandLine);
- CleanupStack::PopAndDestroy(); // commandLine
- return id;
- }
-
- //
- // DLL stuff...
- //
-
- // The gate function - ordinal 1
- EXPORT_C CApaFileRecognizerType* CreateRecognizer()
- {
- return new CPDFFileRecognizer(); // NULL if failed
- }
-
-
- // DLL entry point
- GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
- {
- return KErrNone;
- }
-
-
- #ifdef __WINS__
-
- // MS VC++ 6.0 Introductionary edition version needs this to link
- extern "C" void __pfnBkCheck() {}
-
- #endif