00001
00002
00003
00004
00005
00006
00007
00008 #include "handlerAppUi.h"
00009 #include "handlerDocument.h"
00010 #include "Common.h"
00011
00012 #include <f32file.h>
00013 #include <eikenv.h>
00014 #include <eikappui.h>
00015 #include <eikapp.h>
00016 #include <apparc.h>
00017 #include <eikproc.H>
00018 #include <apgwgnam.h>
00019 #include <avkon.hrh>
00020 #include <aknnotewrappers.h>
00021
00022 CHandlerDocument* CHandlerDocument::NewL(CEikApplication& aApp)
00023 {
00024 CHandlerDocument* self = NewLC(aApp);
00025 CleanupStack::Pop(self);
00026 return self;
00027 }
00028
00029 CHandlerDocument* CHandlerDocument::NewLC(CEikApplication& aApp)
00030 {
00031 CHandlerDocument* self = new (ELeave) CHandlerDocument(aApp);
00032 CleanupStack::PushL(self);
00033 self->ConstructL();
00034 return self;
00035 }
00036
00037 void CHandlerDocument::ConstructL()
00038 {
00039
00040 }
00041
00042 CHandlerDocument::CHandlerDocument(CEikApplication& aApp) : CAknDocument(aApp)
00043 {
00044
00045 }
00046
00047 CHandlerDocument::~CHandlerDocument()
00048 {
00049
00050 }
00051
00052 CEikAppUi* CHandlerDocument::CreateAppUiL()
00053 {
00054
00055
00056 iAppUi = new (ELeave) CHandlerAppUi;
00057 return iAppUi;
00058 }
00059
00060 CFileStore* CHandlerDocument::OpenFileL( TBool aDoOpen, const TDesC& aFilename, RFs& aFs )
00061 {
00062 if (aDoOpen)
00063 {
00064 TFileName name = aFilename;
00065 if( iFileName == name )
00066 {
00067 return NULL;
00068 }
00069 iFileName = name;
00070 CHandlerAppUi *appui = static_cast<CHandlerAppUi *> (iAppUi);
00071 TBuf8<KTextLengthToRead> buf;
00072
00073 RFile file;
00074
00075 TInt err = file.Open(aFs, aFilename, EFileRead|EFileShareAny);
00076 if( err == KErrNone )
00077 {
00078 CleanupClosePushL(file);
00079 User::LeaveIfError( file.Read(buf,KTextLengthToRead) );
00080 CleanupStack::PopAndDestroy();
00081 }
00082 appui->SetFileData(iFileName, buf);
00083 }
00084
00085 return NULL;
00086 }
00087
00088 void CHandlerDocument::OpenFileL(CFileStore*& aFileStore, RFile& aFile)
00089 {
00090 aFileStore = NULL;
00091
00092 TFileName name;
00093 #ifdef __SERIES60_3X__
00094 aFile.Name(name);
00095
00096 #endif
00097
00098
00099
00100 if( iFileName == name)
00101 {
00102 return;
00103 }
00104 iFileName = name;
00105
00106 TBuf8<KTextLengthToRead> buf;
00107 User::LeaveIfError( aFile.Read(buf,KTextLengthToRead) );
00108 CHandlerAppUi *appui = static_cast<CHandlerAppUi *> (iAppUi);
00109 appui->SetFileData(iFileName, buf);
00110 }