00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // 00015 00016 00017 #ifndef __CommonStreamStore_H 00018 #define __CommonStreamStore_H 00019 00020 #include <e32cons.h> 00021 #include <f32file.h> 00022 00023 // public 00024 LOCAL_D CConsoleBase* console; // write all your messages to this 00025 LOCAL_C void doExampleL(); // code this function for the real example 00026 LOCAL_D RFs fsSession; 00027 00028 // private 00029 LOCAL_C void callExampleL(); // initialize with cleanup stack, then do example 00030 00031 _LIT(KTxtStore,"STORE"); 00032 00033 GLDEF_C TInt E32Main() // main function called by E32 00034 { 00035 __UHEAP_MARK; 00036 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack 00037 TRAPD(error,callExampleL()); // more initialization, then do example 00038 __ASSERT_ALWAYS(!error,User::Panic(KTxtStore,error)); 00039 delete cleanup; // destroy clean-up stack 00040 __UHEAP_MARKEND; 00041 return 0; // and return 00042 } 00043 00044 _LIT(KTxtExampleCode,"STORES Example Code"); 00045 _LIT(KTxtConnectFailed,"file session connect failed: return code=%d"); 00046 _LIT(KTxtFailed,"failed: leave code=%d"); 00047 _LIT(KTxtOK,"ok"); 00048 _LIT(KTxtPressAnyKey," [press any key]"); 00049 00050 LOCAL_C void callExampleL() // initialize and call example code under cleanup stack 00051 { 00052 console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen)); 00053 CleanupStack::PushL(console); 00054 TInt fsret = fsSession.Connect(); // start a file session 00055 if (fsret != KErrNone) 00056 { 00057 console->Printf(KTxtConnectFailed,fsret); 00058 User::Leave(fsret); 00059 } 00060 TRAPD(error,doExampleL()); // perform example function 00061 if (error) console->Printf(KTxtFailed, error); 00062 else console->Printf(KTxtOK); 00063 console->Printf(KTxtPressAnyKey); 00064 console->Getch(); // get and ignore character 00065 fsSession.Close(); //close the file session 00066 CleanupStack::PopAndDestroy(); // close console 00067 } 00068 00069 #endif
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.