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

📄 mtmsexampleappui.cpp

📁 series60 应用程序开发的源代码 series60 应用程序开发的源代码
💻 CPP
字号:
/**
* 
* @brief Definition of CMtmsExampleAppUi
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// INCLUDE FILES

// Class include
#include "MtmsExampleAppUi.h"

// System includes
#include <aknnotewrappers.h>    // CAknErrorNote, CAknInformationNote
#include <MtmsExample.rsg>

// User includes
#include "MtmsExampleDialog.h"  // CMtmsExampleDialog
#include "MtmsExampleEngine.h"  // CMtmsExampleEngine
#include "MtmsExample.hrh"      // commands


_LIT(KInvalidMessage, "Message is invalid");
_LIT(KMessageSent, "Message sent!");
_LIT(KMessageUnsent, "Message unsent: %d");


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

/**
* Symbian OS 2nd phase constructor.  Constructs and executes the application's dialog, 
* setting itself as the dialog's MOP parent, and adds it to the control 
* stack.
*/  
void CMtmsExampleAppUi::ConstructL()
{
    BaseConstructL();

    // Create engine
    iEngine = CMtmsExampleEngine::NewL(*this);

    iAppDialog = new (ELeave) CMtmsExampleDialog;
    iAppDialog->SetMopParent(this);
    iAppDialog->ExecuteLD(R_MTMS_EXAMPLE_DIALOG);
    AddToStackL(iAppDialog);    
}


/**
* Destructor.
* Removes the application's dialog from the stack and deletes it.
*/  
CMtmsExampleAppUi::~CMtmsExampleAppUi()
{
    delete iEngine;
    if (iAppDialog)
    {
        RemoveFromStack(iAppDialog);
        delete iAppDialog;
    }
}

/**
* From CEikAppUi, takes care of command handling.
*
* @param aCommand command to be handled
*/
void CMtmsExampleAppUi::HandleCommandL(TInt aCommand)
{
    if (!iEngine->IsReady())
        return;

    switch (aCommand)
    {
        case EMtmsExampleCmdSendSMS:
            if (!GetAddressL())
            {
                break;
            }
            iEngine->CreateDraftSMSL(iAddress);
            if (!iEngine->ValidateSMS())
            {
                NotifyMessageInvalidL();
            }
            else
            {
                iEngine->SendSMSL();
            }
            break;

        case EMtmsExampleCmdSendMMS:
            if (!GetAddressL())
            {
                break;
            }
            iEngine->CreateDraftMMSL(iAddress);
            if (!iEngine->ValidateMMS())
            {
                NotifyMessageInvalidL();
            }
            else
            {
                iEngine->SendMMSL();
            }
            break;

        case EEikCmdExit:
            Exit();
            break;
        
        default:
            break;
    }
}


void CMtmsExampleAppUi::NotifyMessageInvalidL()
{
    CAknErrorNote* note = new (ELeave) CAknErrorNote;
    note->ExecuteLD(KInvalidMessage);
}


TInt CMtmsExampleAppUi::GetAddressL()
{
    CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(iAddress, CAknQueryDialog::ENoTone);
    return dlg->ExecuteLD(R_MTMS_EXAMPLE_ADDRESS_QUERY);
}


void CMtmsExampleAppUi::HandleMessageSentL(TInt aError)
{
    if (aError == KErrNone)
    {
        CAknInformationNote* note = new (ELeave) CAknInformationNote;
        note->ExecuteLD(KMessageSent);
    }
    else
    {
        TBuf<64> buf;
        buf.Format(KMessageUnsent, aError);
        CAknErrorNote* note = new (ELeave) CAknErrorNote;
        note->ExecuteLD(buf);
    }
}


// End of File  

⌨️ 快捷键说明

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