00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <e32base.h>
00018 #include <e32cons.h>
00019 #include "rconnection.h"
00020
00021
00022 _LIT(KRow01,"*****************************************\n");
00023 _LIT(KRow02,"* Welcome to RConnection Example *\n");
00024 _LIT(KRow03,"*****************************************\n");
00025 _LIT(KRow04,"Press a Key to step through the Example\n");
00026 _LIT(KNewLine,"\n");
00027
00028 static void DoStartL(CConsoleBase* aConsole);
00029 static void WelcomeScreen(CConsoleBase* aConsole);
00030 static void CallExampleL();
00031
00032 static void DoStartL(CConsoleBase* aConsole)
00033 {
00034
00035 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
00036 CleanupStack::PushL(scheduler);
00037 CActiveScheduler::Install(scheduler);
00038
00039 CRConnection* example = new (ELeave) CRConnection(aConsole);
00040 CleanupStack::PushL(example);
00041
00042 WelcomeScreen(aConsole);
00043
00044 example->DemoApiWithoutDbOverrideL();
00045
00046 example->DemoApiWithDbOverrideL();
00047
00048 example->AttachToExistingInterfaceL();
00049
00050 CleanupStack::PopAndDestroy(example);
00051
00052
00053 CleanupStack::PopAndDestroy(scheduler);
00054 }
00055
00056 static void CallExampleL()
00057 {
00058 _LIT(KTxtExampleCode,"Symbian platform Example Code");
00059 _LIT(KFormatFailed,"failed: leave code=%d");
00060 _LIT(KTxtOK,"ok");
00061 _LIT(KTxtPressAnyKey," [press any key to exit]");
00062
00063 CConsoleBase* console=Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen));
00064 CleanupStack::PushL(console);
00065
00066 TRAPD(error,DoStartL(console));
00067
00068 if (error)
00069 console->Printf(KFormatFailed, error);
00070 else
00071 console->Printf(KTxtOK);
00072
00073 console->Printf(KTxtPressAnyKey);
00074 console->Getch();
00075
00076 CleanupStack::PopAndDestroy();
00077 }
00078
00079 extern TInt E32Main()
00080 {
00081 _LIT(KEgPanicCat,"EXAMPLES");
00082 __UHEAP_MARK;
00083 CTrapCleanup* cleanup=CTrapCleanup::New();
00084 TRAPD(error,CallExampleL());
00085 __ASSERT_ALWAYS(!error,User::Panic(KEgPanicCat,error));
00086 delete cleanup;
00087 __UHEAP_MARKEND;
00088 return 0;
00089 }
00090
00091
00092 static void WelcomeScreen(CConsoleBase* aConsole)
00093 {
00094 aConsole->ClearScreen();
00095 aConsole->Printf(KRow01);
00096 aConsole->Printf(KRow02);
00097 aConsole->Printf(KRow03);
00098 aConsole->Printf(KNewLine);
00099 aConsole->Printf(KRow04);
00100 aConsole->Getch();
00101 }
00102