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

📄 alarmorganisersecondengine.cpp

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

// INCLUDES

//  Class include
#include "AlarmOrganiserSecondEngine.h"

// Constants

_LIT(KDateString, "%-B%:0%H%:1%T% %D%M%Y%/0%1%/1%2%/2%3%/3");
_LIT(KToDoDateString, "%D%M%Y%/0%1%/1%2%/2%3%/3");
_LIT(KListBoxFormat, "%d \t%S\t\t");
_LIT(KToDoListBoxFormat, "%d\t         %S\t\t");
_LIT(KAlarmOrganiserPanic, "CAlarmOrganiserSecondEngine");

const TInt KSizeOflistBoxDescriptor = 60;
const TInt KSizeOfDateString = 30;
const TInt KInvalidCAgnEntryType = 1;

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

/**
* Symbian OS 2 phase constructor.
* Constructs the CAlarmOrganiserSecondEngine using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
* 
* @param aAlarmOrganiserEngineMixin the engines observer
* @return The newly constructed CAlarmOrganiserSecondEngine
*/
CAlarmOrganiserSecondEngine* CAlarmOrganiserSecondEngine::NewL(MAlarmOrganiserEngineMixin& aAlarmOrganiserEngineMixin)
{
    CAlarmOrganiserSecondEngine* self = CAlarmOrganiserSecondEngine::NewLC(aAlarmOrganiserEngineMixin);
    CleanupStack::Pop(self);
    return self;
}

/**
* Symbian OS 2 phase constructor.
* Constructs the CAlarmOrganiserSecondEngine using the constructor and ConstructL 
* method, leaving the constructed object on the CleanupStack before returning it.
* 
* @param aAlarmOrganiserEngineMixin the engines observer
* @return The newly constructed CAlarmOrganiserSecondEngine
*/
CAlarmOrganiserSecondEngine* CAlarmOrganiserSecondEngine::NewLC(MAlarmOrganiserEngineMixin& aAlarmOrganiserEngineMixin)
{
    CAlarmOrganiserSecondEngine* self = new (ELeave) CAlarmOrganiserSecondEngine(aAlarmOrganiserEngineMixin);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
}

/**
* C++ constructor
* @param aAlarmOrganiserEngineMixin the engines observer
*/
CAlarmOrganiserSecondEngine::CAlarmOrganiserSecondEngine(MAlarmOrganiserEngineMixin& aAlarmOrganiserEngineMixin)
    :CAlarmOrganiserEngineBase(EFalse, aAlarmOrganiserEngineMixin)
{
}

/**
* Adds a CAgnEntry entry without an alarm to the array
* @param aInstanceId Id of the object to be added to array
* @return was the object added?
*/
TBool CAlarmOrganiserSecondEngine::AddL(const TAgnInstanceId& aInstanceId)
{
    CAgnEntry* entry = iModel->FetchInstanceL(aInstanceId);

    // Ignore entry if it has an alarm
    if (entry->HasAlarm())
    {
        delete entry;
        return EFalse;
    }

    // Add the entry to the array, leaves if there is an error.
    TInt error = iArray.Append(entry);    // iArray takes ownership.

    if (error != KErrNone)
    {
        delete entry;
        User::Leave(error);
    }
    
    TTime time;
    TPtrC dateFormatString;
    TPtrC listBoxFormatString;
    
    // Gets the time of the entry, and the format
    // of the descriptor to display time depending on
    // the event type
    switch (entry->Type())
    {
        case CAgnEntry::EAnniv:
        case CAgnEntry::EAppt:
        case CAgnEntry::EEvent:
        {
            dateFormatString.Set(KDateString);
            listBoxFormatString.Set(KListBoxFormat);
            time = entry->InstanceStartDate();
            break;
        }
        case CAgnEntry::ETodo:
        {
            time = entry->InstanceStartDate();
            dateFormatString.Set(KToDoDateString);
            listBoxFormatString.Set(KToDoListBoxFormat);
            break;
        }
        default:
        {
#ifdef _DEBUG
            // We should never reach this point, so panic
            User::Panic(KAlarmOrganiserPanic, KInvalidCAgnEntryType);
#endif // _DEBUG
            break;
        }
    }

    // Format the descriptor string, and add it to the array of descriptors
    TBuf<KSizeOfDateString> dateString;
    time.FormatL(dateString, dateFormatString);
    TBuf<KSizeOflistBoxDescriptor> listBoxDescriptor;
    listBoxDescriptor.Format(listBoxFormatString, iDescriptorArray->Count(), &dateString);    // Numbered from zero.
    iDescriptorArray->AppendL(listBoxDescriptor);

    return ETrue;
}

// End of File

⌨️ 快捷键说明

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