⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 esimdocument.cpp

📁 基于SIP协议的即时消息聊天功能设计,Symbian平台下实现
💻 CPP
字号:
/*
============================================================================
 Name        : CESIMDocument from ESIMDocument.h
 Author      : hagu
 Version     : 
 Description : CESIMDocument implementation
============================================================================
*/

// INCLUDE FILES
#include "ESIMDocument.h"
#include "ESIMAppui.h"

#include "ESIMItemEngine.h"
#include "ESIMUserItem.h"
#include "ESIMGroupItem.h"

const TInt KMaxInfoLength = 1024;

// ================= MEMBER FUNCTIONS =======================

// constructor
CESIMDocument::CESIMDocument(CEikApplication& aApp)
: CAknDocument(aApp)    
    {
    }

// destructor
CESIMDocument::~CESIMDocument()
    {
		TRAPD( Err, SaveL() );//调用appUi的SaveL会在退出时有异常,此处使用是,当整个程序退出的时候,在析构iItemEnginge之前保存其中的数据。
		delete iItemEngine;
		delete iInfoText;
		delete iInfoText2;
    }

// EPOC default constructor can leave.
void CESIMDocument::ConstructL()
    {
		iItemEngine = CESIMItemEngine::NewL();
		iInfoText = HBufC::NewL( KMaxInfoLength );
		iInfoText2 = HBufC::NewL( KMaxInfoLength );
    }

// Two-phased constructor.
CESIMDocument* CESIMDocument::NewL(
        CEikApplication& aApp)     // CESIMApp reference
    {
    CESIMDocument* self = new (ELeave) CESIMDocument( aApp );
    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop();

    return self;
    }
    
// ----------------------------------------------------
// CESIMDocument::CreateAppUiL()
// constructs CESIMAppUi
// ----------------------------------------------------
//
CEikAppUi* CESIMDocument::CreateAppUiL()
    {
    return new (ELeave) CESIMAppUi;
    }

// ---------------------------------------------------------
// CESIMDocument::OpenFileL()
// ---------------------------------------------------------
//
CFileStore* CESIMDocument::OpenFileL( TBool aDoOpen, 
	const TDesC& aFilename, RFs& aFs )
{
	return CEikDocument::OpenFileL( aDoOpen, aFilename, aFs );
}

// ---------------------------------------------------------
// CESIMDocument::StoreL()
// ---------------------------------------------------------
//
void CESIMDocument::StoreL( CStreamStore& aStore, 
	CStreamDictionary& aStreamDic ) const
{
	iItemEngine->ExternalizeL(aStore, aStreamDic, Application()->AppDllUid());
}

// ---------------------------------------------------------
// CESIMDocument::RestoreL()
// ---------------------------------------------------------
//
void CESIMDocument::RestoreL( const CStreamStore& aStore, 
	const CStreamDictionary& aStreamDic )
{
	iItemEngine->InternalizeL(aStore, aStreamDic, Application()->AppDllUid());
}  

// ---------------------------------------------------------
// CESIMItemEngine* CESIMDocument::GetItemEngine()
// ---------------------------------------------------------
//
CESIMItemEngine* CESIMDocument::GetItemEngine()
{
	return iItemEngine;
}

// -----------------------------------------------------------------------------
// CESIMDocument::StoreInfoTextL
// -----------------------------------------------------------------------------
//    
void CESIMDocument::StoreInfoTextL( const TDesC& aText )
{
	__ASSERT_ALWAYS( 
		( aText.Length() + 1 ) < KMaxInfoLength, User::Leave( KErrArgument ) );

	TPtr ptext( iInfoText->Des() );

	TInt appendLen = aText.Length() + 1; // plus one is for line break 

	if ( ( appendLen + iInfoText->Length() ) > KMaxInfoLength )
	{
		ptext.Delete( 0, appendLen );
	}

	ptext.Append( aText );
	ptext.Append( CEditableText::ELineBreak );
}

void CESIMDocument::StoreInfoText2L( const TDesC& aText )
{
	__ASSERT_ALWAYS( 
		( aText.Length() + 1 ) < KMaxInfoLength, User::Leave( KErrArgument ) );

	TPtr ptext( iInfoText2->Des() );

	TInt appendLen = aText.Length() + 1; // plus one is for line break 

	if ( ( appendLen + iInfoText2->Length() ) > KMaxInfoLength )
	{
		ptext.Delete( 0, appendLen );
	}

	ptext.Append( aText );
	ptext.Append( CEditableText::ELineBreak );
}

// -----------------------------------------------------------------------------
// CESIMDocument::InfoText
// -----------------------------------------------------------------------------
//    
const TDesC& CESIMDocument::InfoText()
{
	return *iInfoText;
}

const TDesC& CESIMDocument::InfoText2()
{
	return *iInfoText2;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -