diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/txinstall_8cpp_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/txinstall_8cpp_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,145 @@ + + +
+ +00001 // txin.cpp +00002 // +00003 // © 2006 Nokia Corporation. All rights reserved. +00004 // +00005 +00006 // includes +00007 #include <e32base.h> +00008 #include <e32cons.h> +00009 #include <msvapi.h> +00010 #include <mtclreg.h> +00011 #include <MTUDREG.H> +00012 +00013 #include "txclient.h" +00014 #include "txti.h" +00015 +00016 LOCAL_D CConsoleBase* console; +00017 LOCAL_C void consoleUIInstallL(); +00018 LOCAL_C void DoInstallL(); +00019 _LIT(KMTMDataLocation,"C:\\RESOURCE\\MESSAGING\\MTM\\txtmtm.rsc"); +00020 +00021 _LIT(KTxtTitle,"TextMTM install"); +00022 _LIT(KFormatFailed,"failed: leave code=%d"); +00023 _LIT(KFormatSuccess,"MTM install succeeded"); +00024 +00025 // Dummy observer class to absorb Message Server session events +00026 class TDummyObserver : public MMsvSessionObserver +00027 { +00028 public: +00029 void HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) {}; +00030 }; +00031 +00032 +00033 +00034 LOCAL_C void DoInstallL() +00035 // Set up Message Server session and install Text MTM group +00036 { +00037 +00038 +00039 _LIT(K1, "phase 1 ok \n"); +00040 _LIT(K2, "phase 2 ok \n"); +00041 _LIT(KServiceDirectoryAlreadyCreated, "directory TextMTMService already created on c drive \n"); +00042 _LIT(KServiceDirectoryCreated, "directory TextMTMService service created on c drive \n"); +00043 +00044 +00045 TDummyObserver ob; +00046 CMsvSession* session = CMsvSession::OpenSyncL(ob); +00047 CleanupStack::PushL(session); +00048 TInt err=session->DeInstallMtmGroup(KMTMDataLocation); +00049 if (err!=KErrNone && err!=KErrNotFound) +00050 User::Leave(err); +00051 User::LeaveIfError(session->InstallMtmGroup(KMTMDataLocation)); +00052 +00053 // Installing is ok +00054 console->Printf(K1); +00055 +00056 +00057 CClientMtmRegistry* cl = CClientMtmRegistry::NewL(*session); +00058 if(!cl->IsPresent(KUidMsgTypeText)) User::Leave(KErrNotFound); +00059 +00060 // Resource file was found +00061 console->Printf(K2); +00062 +00063 CTextMtmClient* climpl=NULL; +00064 climpl = (CTextMtmClient*)cl->NewMtmL(KUidMsgTypeText); +00065 +00066 +00067 delete climpl; +00068 delete cl; +00069 +00070 CleanupStack::PopAndDestroy(session); // session +00071 +00072 RFs fs; +00073 fs.Connect(); +00074 +00075 _LIT(KNewDir,"\\data\\TextMTMService\\"); +00076 +00077 // Try to create the directory +00078 TInt err4 = fs.MkDir(KNewDir); +00079 +00080 // In case the directory is already there... +00081 if (err4==KErrAlreadyExists) +00082 { +00083 console->Printf(KServiceDirectoryAlreadyCreated); +00084 } +00085 +00086 // Directory not yet created... +00087 else if (err4==KErrNone) +00088 { +00089 console->Printf(KServiceDirectoryCreated); +00090 +00091 } +00092 +00093 +00094 fs.Close(); +00095 +00096 +00097 } +00098 +00099 LOCAL_C void consoleUIInstallL() +00100 // Set up simple console UI +00101 { +00102 // Construct and install the active scheduler +00103 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; +00104 CleanupStack::PushL(scheduler); +00105 CActiveScheduler::Install(scheduler); +00106 +00107 console=Console::NewL(KTxtTitle,TSize(KConsFullScreen,KConsFullScreen)); +00108 CleanupStack::PushL(console); +00109 +00110 +00111 TRAPD(error,DoInstallL()); // call install function +00112 if (error != KErrNone) +00113 console->Printf(KFormatFailed, error); +00114 else +00115 console->Printf(KFormatSuccess); +00116 console->Getch(); +00117 CleanupStack::PopAndDestroy(2, scheduler); // console, scheduler +00118 } +00119 +00120 GLDEF_C TInt E32Main() +00121 { +00122 __UHEAP_MARK; +00123 CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack +00124 TRAPD(error,consoleUIInstallL()); +00125 delete cleanup; // destroy clean-up stack +00126 __UHEAP_MARKEND; +00127 return error; +00128 } +00129 +