chatbase.cpp

来自「一个聊天的软件」· C++ 代码 · 共 196 行

CPP
196
字号
/*
* ==============================================================================
*  Name        : ChatBase.cpp
*  Part of     : Chat
*  Interface   : 
*  Description : 
*  Version     : 
*
*  Copyright (c) 2005-2006 Nokia Corporation.
*  This material, including documentation and any related 
*  computer programs, is protected by copyright controlled by 
*  Nokia Corporation.
* ==============================================================================
*/

// INCLUDE FILES
#include <ChatEx.rsg>
#include "ChatBase.h"
#include "Chat.pan"
#include "Log.h"
#include <StringLoader.h>


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

// ----------------------------------------------------------------------------
// CChatBase::NewL()
// Two-phased constructor.
// ----------------------------------------------------------------------------
//
CChatBase* CChatBase::NewL( MLog& aLog )
    {
    CChatBase* self = NewLC( aLog );
    CleanupStack::Pop( self );
    return self;
    }

// ----------------------------------------------------------------------------
// CChatBase::NewLC()
// Two-phased constructor.
// ----------------------------------------------------------------------------
//
CChatBase* CChatBase::NewLC( MLog& aLog )
    {
    CChatBase* self = new ( ELeave ) CChatBase( aLog );
    CleanupStack::PushL( self );
    self->ConstructL ();
    return self;
    }

// ----------------------------------------------------------------------------
// CChatBase::ConstructL()
// Perform second phase construction of this object.
// ----------------------------------------------------------------------------
//
void CChatBase::ConstructL()
    {
    // no implementation required
    }

// ----------------------------------------------------------------------------
// CChatBt::CChatBt()
// Constructor.
// ----------------------------------------------------------------------------
//
CChatBase::CChatBase( MLog& aLog )
    : CActive( CActive::EPriorityStandard ),
    iState( EWaitingToGetDevice ),
    iLog( aLog ),
    iServerMode( EFalse )
    {
    CActiveScheduler::Add( this );
    }

// ----------------------------------------------------------------------------
// CChatBase::~CChatBase()
// Destructor.
// ----------------------------------------------------------------------------
//
CChatBase::~CChatBase()
    {
  
    }
    
// ----------------------------------------------------------------------------
// CChatBase::DoCancel()
// Cancel any outstanding requests.
// ----------------------------------------------------------------------------
//
void CChatBase::DoCancel()
    {
    // no implementation required
    }

// ----------------------------------------------------------------------------
// CChatBase::RunL()
// Respond to an event.
// ----------------------------------------------------------------------------
//
void CChatBase::RunL()
    {
    // no implementation required
    }
    
// ----------------------------------------------------------------------------
// CChatBase::IsServer()
// True if the acting as server.
// ----------------------------------------------------------------------------
//
TBool CChatBase::Server()
    {
    return iServerMode;
    }    

// ----------------------------------------------------------------------------
// CChatBase::SetServer()
// 
// ----------------------------------------------------------------------------
//
void CChatBase::SetServer( TBool aServerMode )
    {
    iServerMode = aServerMode;
    }          

// ----------------------------------------------------------------------------
// CChatBase::SetState()
// 
// ----------------------------------------------------------------------------
//
void CChatBase::SetState( TChatState aState )
  {
  iState = aState;
  }

// ----------------------------------------------------------------------------
// CChatBase::State()
// 
// ----------------------------------------------------------------------------
//    
TInt CChatBase::State()
  {
  return iState;
  }

// ----------------------------------------------------------------------------
// CChatBase::IsReadyToSendMessage()
// True if the client can send a message.
// ----------------------------------------------------------------------------
//
TBool CChatBase::IsReadyToSendMessage()
    {
    return ( State() == EConnected );
    }

// ----------------------------------------------------------------------------
// CChatBase::IsConnected()
// True if the client can send a message.
// ----------------------------------------------------------------------------
//
TBool CChatBase::IsConnected()
    {
    return ( ( State() == EConnected )||( State() == ESendingMessage ) );
    }
    

// ----------------------------------------------------------------------------
// CChatBase::IsConnecting()
// True if is establishing a connection.
// ----------------------------------------------------------------------------
//
TBool CChatBase::IsConnecting()
    {
    return ( ( State() == EGettingDevice )
        ||
        ( State() == EGettingService )
        ||
        ( State() == EGettingConnection )
        || 
        ( State() == EConnecting )  
        );
    }

// ----------------------------------------------------------------------------
// CChatBase::IsSendingMessage()
// True if the client is connected.
// ----------------------------------------------------------------------------
//
TBool CChatBase::IsSendingMessage()
    {
    return ( State() == ESendingMessage );
    }




⌨️ 快捷键说明

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