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

📄 cmsvhandler.cpp

📁 Symbian 手机发送彩信程序 mmssend
💻 CPP
字号:
/*  Copyright (c) 2004, Nokia. All rights reserved */

// INCLUDE FILES
#include <eikenv.h>
#include <msvids.h>
#include <mtclreg.h>
#include <mtclbase.h>
#include <txtrich.h>

#include "CMsvHandler.h"

// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------------------------
// CMsvHandler::CMsvHandler()
// Add active scheduler
// ----------------------------------------------------------------------------
//
CMsvHandler::CMsvHandler( MMsvObserver& aObserver )
    :   CActive( EPriorityStandard ), iOperation( NULL ),
        iSession( NULL ), iMtm( NULL ), iMtmRegistry( NULL ),
        iObserver( aObserver )
    {
    CActiveScheduler::Add( this );
    }

// ----------------------------------------------------------------------------
// CMsvHandler::IsIdle()
// return ETrue if session established, else return false
// ----------------------------------------------------------------------------
//
TBool CMsvHandler::IsIdle()
    {
    // The session must have been established to have created an MtmRegistry
    return ( iMtmRegistry ? ETrue : EFalse );
    }

// ----------------------------------------------------------------------------
// CMsvHandler::CMsvHandler()
// Destructor
// Cancels active objects and releases reserved resources
// ----------------------------------------------------------------------------
//
CMsvHandler::~CMsvHandler()
    {
    Cancel(); // Causes call to DoCancel() if active

    delete iOperation;

    delete iMtm;

    delete iMtmRegistry;

	delete iSession;    // session must be deleted last (and constructed first)
    }

// ----------------------------------------------------------------------------
// CMsvHandler::ConstructL()
// Create CMsvSession. The server reports completion via the
// MMsvSessionObserver::HandleSessionEventL. Clients may use
// the session only when this event has been consumed.
// ----------------------------------------------------------------------------
//
void CMsvHandler::ConstructL()
    {
    iSession = CMsvSession::OpenAsyncL( *this );
    }

// ----------------------------------------------------------------------------
// CMsvHandler::CompleteConstructL()
// We get a MtmClientRegistry from our session
// this registry is used to instantiate new mtms.
// ----------------------------------------------------------------------------
//
void CMsvHandler::CompleteConstructL()
    {
    iMtmRegistry = CClientMtmRegistry::NewL( *iSession );
    }

// ----------------------------------------------------------------------------
// CMsvHandler::DoCancel()
// Cancels active object to do it's operation
// ----------------------------------------------------------------------------
//
void CMsvHandler::DoCancel()
    {
    // Cancel any outstanding operations
    if ( iOperation )
        {
        iOperation->Cancel();
        }
    }

// ----------------------------------------------------------------------------
// CMsvHandler::SetMtmEntryL()
// Set Mtm entry for the message
// ----------------------------------------------------------------------------
//
void CMsvHandler::SetMtmEntryL( TMsvId aEntryId )
    {
    // Get the server entry from our session
    CMsvEntry* entry = iSession->GetEntryL( aEntryId );
    CleanupStack::PushL( entry );

    // Check if our mtm is different from the mtm set to our entry,and it's not empty
    if ( ( iMtm == NULL ) || (entry->Entry().iMtm != (iMtm->Entry()).Entry().iMtm) )
        {
        // If so, we delete the old...
        delete iMtm;
        iMtm = NULL;

        // ...and get a new one from the MtmRegistry
        iMtm = iMtmRegistry->NewMtmL( entry->Entry().iMtm );
        }

    iMtm->SetCurrentEntryL( entry );
    CleanupStack::Pop( entry );
    }

// End of File

⌨️ 快捷键说明

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