📄 msgobserverappui.cpp
字号:
/**
*
* @brief Definition of CMsgObserverAppUi
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
#include "MsgObserverAppUi.h"
#include <avkon.hrh>
#include <MsgObserver.rsg>
#include <msvids.h>
#include <txtrich.h> // CRichText
#include "MsgObserverContainer.h"
#include "msgobserver.hrh"
_LIT(KNoBodyText, "Message has no body");
#ifdef __WINS__
const TMsvId KObservedFolderId = KMsvDraftEntryId;
#else
const TMsvId KObservedFolderId = KMsvGlobalInBoxIndexEntryId;
#endif
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CMsgObserverAppUi::ConstructL()
// ?implementation_description
// ----------------------------------------------------------
//
void CMsgObserverAppUi::ConstructL()
{
BaseConstructL();
iAppContainer = new (ELeave) CMsgObserverContainer;
iAppContainer->SetMopParent(this);
iAppContainer->ConstructL( ClientRect() );
AddToStackL( iAppContainer );
iMsvSession = CMsvSession::OpenAsyncL(*this);
}
// ----------------------------------------------------
// CMsgObserverAppUi::~CMsgObserverAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CMsgObserverAppUi::~CMsgObserverAppUi()
{
if (iAppContainer)
{
RemoveFromStack( iAppContainer );
delete iAppContainer;
}
delete iMsvEntry;
delete iMsvSession;
}
// ------------------------------------------------------------------------------
// CMsgObserverAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
// This function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ------------------------------------------------------------------------------
//
void CMsgObserverAppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CMsgObserverAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// ?implementation_description
// ----------------------------------------------------
//
TKeyResponse CMsgObserverAppUi::HandleKeyEventL(
const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
// ----------------------------------------------------
// CMsgObserverAppUi::HandleCommandL(TInt aCommand)
// ?implementation_description
// ----------------------------------------------------
//
void CMsgObserverAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyBack:
case EEikCmdExit:
{
Exit();
break;
}
default:
break;
}
}
void CMsgObserverAppUi::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/)
{
switch (aEvent)
{
case EMsvServerReady:
// Initialise iMsvEntry
if (!iMsvEntry)
{
iMsvEntry = CMsvEntry::NewL(*iMsvSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
}
break;
case EMsvEntriesCreated:
// Only look for changes in the Inbox
if (*(static_cast<TMsvId*>(aArg2)) == KObservedFolderId)
{
CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
iNewMessageId = entries->At(0);
}
break;
case EMsvEntriesChanged:
// Only look for changes in the Inbox
if (*(static_cast<TMsvId*>(aArg2)) == KObservedFolderId)
{
CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>(aArg1);
if (iNewMessageId == entries->At(0))
{
// It's the same message we received the EMsvEntriesCreated event for
// Set entry context to the new message
iMsvEntry->SetEntryL(iNewMessageId);
// Open the store, read-only
CMsvStore* store = iMsvEntry->ReadStoreL();
CleanupStack::PushL(store);
// Get body text and send it to the container
if (store->HasBodyTextL())
{
CRichText* richText = CRichText::NewL(
iEikonEnv->SystemParaFormatLayerL(),
iEikonEnv->SystemCharFormatLayerL());
CleanupStack::PushL(richText);
store->RestoreBodyTextL(*richText);
const TInt length = richText->DocumentLength();
iAppContainer->SetTextL(richText->Read(0, length));
CleanupStack::PopAndDestroy(richText);
}
else
{
iAppContainer->SetTextL(KNoBodyText);
}
CleanupStack::PopAndDestroy(store);
}
}
break;
default:
break;
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -