examples/Messaging/TextMTM/txin/txin.cpp

00001 // Copyright (c) 1999-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 // includes
00017 #if !defined(__E32BASE_H__)
00018 #include <e32base.h>
00019 #endif
00020 #if !defined(__E32CONS_H__)
00021 #include <e32cons.h>
00022 #endif
00023 #if !defined(__MSVAPI_H__)
00024 #include <msvapi.h>
00025 #endif
00026 
00027 LOCAL_D CConsoleBase* console; 
00028 LOCAL_C void consoleUIInstallL(); 
00029 LOCAL_C void DoInstallL();
00030 
00031 // constants
00032 #ifdef __WINS__
00033 _LIT(KMTMDataFullName,"z:\\Resource\\messaging\\mtm\\txtmtm.RSC");
00034 #else
00035 _LIT(KMTMDataFullName,"Z:\\Resource\\messaging\\mtm\\txtmtm.RSC");
00036 #endif
00037 
00038 
00039 _LIT(KTxtPressAnyKey," [press any key to exit]");
00040 
00041 // Dummy observer class to absorb Message Server session events
00042 class TDummyObserver : public MMsvSessionObserver
00043         {
00044 public:
00045         void HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) {};
00046         };
00047 
00048 LOCAL_C void DoInstallL()
00049 // Set up Message Server session and install Text MTM group
00050         {
00051         TDummyObserver ob;
00052         CMsvSession* session = CMsvSession::OpenSyncL(ob);
00053         CleanupStack::PushL(session);
00054         TInt err=session->DeInstallMtmGroup(KMTMDataFullName);
00055         if (err!=KErrNone && err!=KErrNotFound)
00056                 User::LeaveIfError(err);
00057         User::LeaveIfError(session->InstallMtmGroup(KMTMDataFullName));
00058 
00059         CleanupStack::PopAndDestroy(); // session
00060         }
00061 
00062 LOCAL_C void consoleUIInstallL() 
00063 // Set up simple console UI
00064     {
00065         _LIT(KTxtTitle,"TextMTM installed");
00066         _LIT(KFormatFailed,"failed: leave code=%d");
00067 
00068         // Construct and install the active scheduler
00069         CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
00070         CleanupStack::PushL(scheduler);
00071         CActiveScheduler::Install(scheduler); 
00072 
00073         console=Console::NewL(KTxtTitle,TSize(KConsFullScreen,KConsFullScreen));
00074         CleanupStack::PushL(console);
00075         
00076         
00077         TRAPD(error,DoInstallL()); // call install function
00078         if (error)
00079                 console->Printf(KFormatFailed, error);
00080         else 
00081                 console->Printf(KTxtTitle);
00082         console->Printf(KTxtPressAnyKey);
00083         console->Getch();
00084         CleanupStack::PopAndDestroy(2); // scheduler, console
00085                         
00086         
00087         }
00088 
00089 GLDEF_C TInt E32Main()
00090         {
00091         __UHEAP_MARK;
00092         CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
00093         TRAPD(error,consoleUIInstallL()); 
00094         delete cleanup; // destroy clean-up stack
00095         __UHEAP_MARKEND;
00096         return error; 
00097     }

Generated on Thu Jan 21 10:32:59 2010 for TB10.1 Example Applications by  doxygen 1.5.3