Nokia N97 SDK
Example Applications Guide

CommonFramework.h File Reference


Detailed Description

Definition in file CommonFramework.h.

#include <e32base.h>
#include <e32cons.h>

Go to the source code of this file.


Functions

  _LIT (KTxtEPOC32EX,"EXAMPLES")
  _LIT (KTxtExampleCode,"Symbian OS Example Code")
  _LIT (KFormatFailed,"failed: leave code=%d")
  _LIT (KTxtOK,"ok")
  _LIT (KTxtPressAnyKey,"\n[press any key]\n")
LOCAL_C void  doExampleL ()
LOCAL_C void  callExampleL ()
GLDEF_C TInt  E32Main ()

Variables

LOCAL_D CConsoleBase *  console


Function Documentation

void doExampleL (   ) 
 

main-function of the DriveInfo console application

checks commandline arguments and then displays drive information either for all available drives or the ones specified in commandline

Definition at line 49 of file DriveInfo.cpp.

References fsSession, PrintAllDrivesVolInfo(), and PrintDriveVolInfo().

Referenced by callExampleL().

00050 {
00051     CCommandLineArguments *cmdline = CCommandLineArguments::NewLC();
00052 
00053     // Connect to file server
00054     User::LeaveIfError(fsSession.Connect()); // Start session
00055     CleanupClosePushL( fsSession );
00056 
00057     TInt count = cmdline->Count();
00058     if (count > 1)
00059     {
00060         // skip commandline argument 0, because that is the name of the exe
00061         for (TInt i=1; i<count; ++i)
00062         {
00063             TPtrC arg = cmdline->Arg(i);
00064             PrintDriveVolInfo(arg);
00065         }
00066     }
00067     else // show all
00068     {
00069         PrintAllDrivesVolInfo();
00070     }
00071 
00072     CleanupStack::PopAndDestroy(2, cmdline); // cmdline, fsSession
00073 }

LOCAL_C void callExampleL (   ) 
 

creates console and calls example code under cleanup stack

Definition at line 46 of file CommonFramework.h.

References console, and doExampleL().

Referenced by E32Main().

00047 {
00048     console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
00049     CleanupStack::PushL(console);
00050     TRAPD(error,doExampleL()); // perform example function
00051     if (error)
00052         console->Printf(KFormatFailed, error);
00053     else
00054         console->Printf(KTxtOK);
00055     console->Printf(KTxtPressAnyKey);
00056     console->Getch(); // get and ignore character
00057     CleanupStack::PopAndDestroy(); // close console
00058 }

TInt E32Main (   ) 
 

main function called by E32. Creates clean-up stack and calls example initialization function

Definition at line 31 of file CommonFramework.h.

References callExampleL().

00032 {
00033     __UHEAP_MARK;
00034     CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
00035     TRAPD(error,callExampleL()); // more initialization, then do example
00036     __ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
00037     delete cleanup; // destroy clean-up stack
00038     __UHEAP_MARKEND;
00039     return 0; // and return
00040 }


© Nokia 2009

Back to top