00001 00002 00003 // INCLUDE FILES 00004 00005 // UIKON/AVKON 00006 #include <akntitle.h> // CAknTitlePane 00007 #include <eikmenub.h> // CEikMenuBar 00008 #include <aknnotewrappers.h> // AknNoteWrappers 00009 #include <txtrich.h> // Rich text 00010 #include <f32file.h> 00011 00012 // messaging editors 00013 #include <eikrted.h> // CEikRichTextEditor 00014 00015 // local 00016 #include "txtviewer.hrh" // application specific commands 00017 #include "txtviewerappview.h" // CTxtViewerDocument 00018 #include "txtviewerappui.h" // CTxtViewerAppUi 00019 #include "txtviewerdoc.h" // CTxtViewerAppUi 00020 #include "../../UI/inc/txtu.h" 00021 #include <msvids.h> 00022 00023 // Find item 00024 // general 00025 #include <CentralRepository.h> 00026 00027 #include <txtviewer.rsg> 00028 // Txt editor executable Uid 00029 const TUid KUidTxtViever ={0xA00058BC}; 00030 _LIT(KTextMTMMsgPath, "C:\\data\\TextMTMService\\"); 00031 00032 // Txt Mtm Service Uid 00033 const TUid KUidTxtMtm = {0x10FFFFFF}; 00034 00035 00036 00037 // ================= MEMBER FUNCTIONS ======================= 00038 00039 // C++ default constructor can NOT contain any code, that 00040 // might leave. 00041 CTxtViewerAppUi::CTxtViewerAppUi() 00042 { 00043 } 00044 00045 // Symbian OS default constructor can leave. 00046 void CTxtViewerAppUi::ConstructL() 00047 { 00048 BaseConstructL(EAknEnableSkin); 00049 iAppView = CTxtViewerAppView::NewL( ClientRect() ); 00050 AddToStackL( iAppView ); 00051 Document()->SetView(iAppView); 00052 } 00053 00054 00055 // Destructor 00056 CTxtViewerAppUi::~CTxtViewerAppUi() 00057 { 00058 00059 if (iAppView) 00060 { 00061 RemoveFromStack(iAppView); 00062 delete iAppView; 00063 00064 } 00065 } 00066 00067 // --------------------------------------------------------- 00068 // CTxtViewerAppUi::Document 00069 // (other items were commented in a header). 00070 // --------------------------------------------------------- 00071 CTxtViewerDocument* CTxtViewerAppUi::Document() const 00072 { 00073 return static_cast<CTxtViewerDocument*>(CEikAppUi::Document()); 00074 } 00075 00076 00077 00078 // --------------------------------------------------------- 00079 // CTxtViewerAppUi::DynInitMenuPaneL 00080 // (other items were commented in a header). 00081 // --------------------------------------------------------- 00082 void CTxtViewerAppUi::DynInitMenuPaneL( 00083 TInt aMenuId, 00084 CEikMenuPane* aMenuPane ) 00085 { 00086 switch ( aMenuId ) 00087 { 00088 case R_TEXTMTMVIEW_MENU: 00089 { 00090 if ( !iAppView->OpenedForEditing() ) // editor 00091 { 00092 aMenuPane->SetItemDimmed( ETxtViewerSend, ETrue ); 00093 aMenuPane->SetItemDimmed( ETxtViewerSaveToDrafts, ETrue ); 00094 00095 } 00096 } 00097 } 00098 } 00099 00100 // --------------------------------------------------------- 00101 // CTxtViewerAppUi::HandleCommandL 00102 // (other items were commented in a header). 00103 // --------------------------------------------------------- 00104 void CTxtViewerAppUi::HandleCommandL(TInt aCommand ) 00105 { 00106 00107 00108 switch( aCommand ) 00109 { 00110 case EEikCmdExit: 00111 case EAknSoftkeyExit: 00112 case EAknSoftkeyBack: 00113 Exit(); 00114 00115 case ETxtViewerSend: 00116 00117 iAppView->SaveBodyL(); 00118 SendL(); 00119 Exit(); 00120 break; 00121 00122 case ETxtViewerSaveToDrafts: 00123 00124 iAppView->SaveBodyL(); 00125 SaveToDraftsL(); 00126 Exit(); 00127 break; 00128 00129 00130 default: 00131 00132 break; 00133 } 00134 } 00135 00136 // --------------------------------------------------------- 00137 // CTxtViewerAppUi::HandleKeyEventL 00138 // (other items were commented in a header). 00139 // --------------------------------------------------------- 00140 TKeyResponse CTxtViewerAppUi::HandleKeyEventL( 00141 const TKeyEvent& /*aKeyEvent*/, 00142 TEventCode /*aType*/ ) 00143 { 00144 return EKeyWasConsumed; 00145 } 00146 00147 void CTxtViewerAppUi::SaveToDraftsL() 00148 { 00149 CTextMtmUi* iMtmUi = iAppView->UiMtm(); 00150 00151 iMtmUi->BaseMtm().SwitchCurrentEntryL(Document()->Id()); 00152 00153 TMsvEntry entry = iMtmUi->BaseMtm().Entry().Entry(); 00154 00155 // These flags must be set 00156 entry.SetInPreparation(EFalse); 00157 00158 entry.SetVisible(ETrue); 00159 00160 entry.iServiceId = KMsvLocalServiceIndexEntryId; 00161 00162 CMsvEntry& msventry = iMtmUi->BaseMtm().Entry(); 00163 00164 msventry.ChangeL(entry); 00165 00166 00167 } 00168 00169 void CTxtViewerAppUi::SendL() 00170 { 00171 CTextMtmUi* iMtmUi = iAppView->UiMtm(); 00172 00173 00174 // Creata a new entry selection array 00175 CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection(); 00176 00177 CleanupStack::PushL(selection); 00178 00179 TMsvEntry entry = iMtmUi->BaseMtm().Entry().Entry(); 00180 00181 00182 // These flags must be set before sending 00183 entry.SetInPreparation(EFalse); 00184 00185 entry.SetVisible(ETrue); 00186 00187 entry.iServiceId = KMsvLocalServiceIndexEntryId; 00188 00189 CMsvEntry& msventry = iMtmUi->BaseMtm().Entry(); 00190 00191 msventry.SetEntryL(Document()->Id()); 00192 00193 msventry.ChangeL(entry); 00194 // Add the edited item to the array 00195 selection->AppendL(Document()->Id()); 00196 00197 iMtmUi->BaseMtm().SwitchCurrentEntryL(KMsvSentEntryId/*iMtmUi->BaseMtm().DefaultServiceL()*/); 00198 00199 CMsvOperationActiveSchedulerWait* wait=CMsvOperationActiveSchedulerWait::NewLC(); 00200 00201 CMsvOperation* op = NULL; 00202 00203 op = iMtmUi->MoveToL(*selection, wait->iStatus); 00204 00205 CleanupStack::PushL(op); 00206 00207 wait->Start(); 00208 00209 RFile file; 00210 RFs fs; 00211 fs.Connect(); 00212 TBuf<256> filename; 00213 filename.Append(KTextMTMMsgPath); 00214 filename.Append(_L("message")); 00215 _LIT(KTimeFormat,"%H%T"); 00216 TBuf <10> timeBuf; 00217 TTime myTime; 00218 myTime.HomeTime(); 00219 myTime.FormatL(timeBuf, KTimeFormat); 00220 filename.Append(timeBuf); 00221 filename.Append(_L(".txt")); 00222 00223 if (file.Open(fs, filename,EFileWrite) == KErrNotFound) 00224 { 00225 file.Create(fs, filename,EFileWrite); 00226 } 00227 TInt pos; 00228 file.Seek(ESeekEnd, pos); 00229 00230 file.Close(); 00231 fs.Close(); 00232 00233 iAppView->ExportToFileL( filename ); 00234 00235 CleanupStack::PopAndDestroy(3); 00236 } 00237 00238 00239 // --------------------------------------------------------- 00240 // CTxtViewerAppUi::HandleStatusPaneSizeChange() 00241 // Called by framework when resource is changed. 00242 // --------------------------------------------------------- 00243 // 00244 void CTxtViewerAppUi::HandleStatusPaneSizeChange() 00245 { 00246 CAknAppUi::HandleStatusPaneSizeChange(); //call to upper class 00247 iAppView->SetRect( ClientRect() ); 00248 }
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.