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

📄 httpclientappui.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CHttpClientAppUi from HttpClientAppui.cpp
*  Part of  : HttpClient
*  Created  : 07.03.2006 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include <aknnotewrappers.h> // for CAknInformationNote
#include <eikmenup.h>        // for CEikMenuPane
#include <HttpClient.rsg>

#include "HttpClient.hrh"
#include "HttpClientAppui.h"
#include "HttpClientContainer.h" 
#include "HttpClientQuery.h"

#include <avkon.hrh>


// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CHttpClientAppUi::ConstructL()
// 
// ----------------------------------------------------------
//
void CHttpClientAppUi::ConstructL()
    {
    BaseConstructL();

    iAppContainer = new (ELeave) CHttpClientContainer;
    iAppContainer->SetMopParent( this );
    iAppContainer->ConstructL( ClientRect() );
    AddToStackL( iAppContainer );

    iEngine = CHttpClientEngine::NewL(*this);
    }

// ----------------------------------------------------
// CHttpClientAppUi::~CHttpClientAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CHttpClientAppUi::~CHttpClientAppUi()
    {
    if (iAppContainer)
        {
        RemoveFromStack( iAppContainer );
        delete iAppContainer;
        }
    delete iEngine;
    }

void CHttpClientAppUi::OnHeaderL(TInt aStatusCode, const TDesC& aStatusText)
    {
    HBufC* buf = HBufC::NewLC(aStatusText.Length() + 10);
    TPtr ptr = buf->Des();
    ptr.AppendNum(aStatusCode);
    ptr.Append(' ');
    ptr.Append(aStatusText);
    CAknInformationNote* note = new (ELeave) CAknInformationNote;
    note->ExecuteLD(*buf);
    CleanupStack::PopAndDestroy(buf);
    }

void CHttpClientAppUi::OnBodyL(const TDesC& aBody)
    {
    iAppContainer->AppendL(aBody);
    }

// ------------------------------------------------------------------------------
// CHttpClientAppUi::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 CHttpClientAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
    {
    if(aResourceId==R_HTTPCLIENT_MENU)
        {
        if(iEngine->IsGetting())
            {
            aMenuPane->SetItemDimmed(EHttpClientCmdGet, ETrue);
            }
        else
            {
            aMenuPane->SetItemDimmed(EHttpClientCmdCancel, ETrue);
            }
        }
    }

// ----------------------------------------------------
// CHttpClientAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CHttpClientAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
        {
        case EAknSoftkeyBack:
        case EEikCmdExit:
            {
            Exit();
            break;
            }
        case EHttpClientCmdGet:
            {
            _LIT(KDefaultUri, "http://www.baidu.com/");
            HBufC* buf = HBufC::NewLC(KUrlMaxLength);
            TPtr ptr = buf->Des();
            ptr.Copy(KDefaultUri());
            CHttpClientQuery* dlg = new(ELeave) CHttpClientQuery(ptr);
            if(dlg->ExecuteLD(R_HTTPCLIENT_QUERY))
                {
                iEngine->GetL(*buf);
                };
            CleanupStack::PopAndDestroy();
            break;
            }
        case EHttpClientCmdCancel:
            {
            iEngine->Cancel();
            }
        default:
            break;      
        }
    }



// End of File  

⌨️ 快捷键说明

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