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

📄 logexeventform.cpp

📁 专业的用于查询手机通话记录的代码
💻 CPP
字号:
/*
 * ============================================================================
 *  Name     : CLogExEventForm from LogExEventForm.h
 *  Part of  : LogExample
 *  Created  : 26.05.2005 by Forum Nokia  
 *  Implementation notes:
 *  Version  : 1.0
 *  Copyright: Nokia Corporation
 * ============================================================================*/

//INCLUDE FILES
#include "LogExEventForm.h"
#include <logexample.rsg>
#include <eikedwin.h> // CEikEdwin

#ifdef __SERIES60_3X__
#include <tz.h>  // RTz
#include <tzconverter.h>  // CTzConverter
#endif

#include "logexample.hrh"

//CONSTANTS
_LIT(KNoData,"No data");
const TInt KBufSize = 32;
const TInt KAppendFormat = 32;

// ================= PUBLIC =======================

// ----------------------------------------------------------
// CLogExEventForm::NewL(CLogEvent& aLogEvent)
// Two phased constructor
// ----------------------------------------------------------
//
CLogExEventForm* CLogExEventForm::NewL(CLogEvent& aLogEvent)
    {
    CLogExEventForm* self = new (ELeave) CLogExEventForm(aLogEvent);
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

// ================= PRIVATE =======================

// ----------------------------------------------------------
// CLogExEventForm::CLogExEventForm(CLogEvent& aLogEvent):iLogEvent(aLogEvent)
// Default constructor
// ----------------------------------------------------------
//
CLogExEventForm::CLogExEventForm(CLogEvent& aLogEvent) :
    iLogEvent(aLogEvent)
    {
    }

// ----------------------------------------------------------
// CLogExEventForm::PreLayoutDynInitL()
// Initializes the form from the base class
// ----------------------------------------------------------
//
void CLogExEventForm::PreLayoutDynInitL()
    {
    CAknForm::PreLayoutDynInitL();

    CEikEdwin* formField1 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin01));
    if (formField1)
        {
        HBufC* name = iLogEvent.Direction().AllocLC(); // Direction field
        formField1->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField2 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin02));
    if (formField2)
        {
        HBufC* name = iLogEvent.Description().AllocLC(); // Description field
        formField2->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField3 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin03));
    if (formField3)
        {
        TBuf<KMaxTimeFormatSpec> buffer;
        TTime time = iLogEvent.Time();
        // In 3rd Ed., convert time (UTC) to local time
        #ifdef __SERIES60_3X__
        UTCToLocalTimeL(time);
        #endif
        time.FormatL(buffer, TTimeFormatSpec()); // Time field
        HBufC* name = buffer.AllocLC();
        formField3->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField4 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin04));
    if (formField4)
        {
        TBuf<KMaxShortDateFormatSpec> buffer;
        iLogEvent.Time().FormatL(buffer, TShortDateFormatSpec()); // Date field
        HBufC* name = buffer.AllocLC();
        formField4->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField5 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin05));
    if (formField5)
        {
        HBufC* name = iLogEvent.RemoteParty().AllocLC(); // RemoteParty field
        formField5->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField6 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin06));
    if (formField6)
        {
        HBufC* name = iLogEvent.Number().AllocLC(); // Number field
        formField6->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField7 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin07));
    if (formField7)
        {
        HBufC* name = iLogEvent.Subject().AllocLC(); // Subject field
        formField7->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField8 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin08));
    if (formField8)
        {
        TBuf<KBufSize> buffer;
        buffer.AppendNum(iLogEvent.Duration(), KAppendFormat); // Duration field
        HBufC* name = buffer.AllocLC();
        formField8->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField9 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin09));
    if (formField9)
        {
        TBuf<KBufSize> buffer;
        buffer.AppendNum(iLogEvent.DurationType(), KAppendFormat); // DurationType field
        HBufC* name = buffer.AllocLC();
        formField9->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField10 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin10));
    if (formField10)
        {
        TBuf<KBufSize> buffer;
        buffer.AppendNum(iLogEvent.Id(), KAppendFormat); // Id field
        HBufC* name = buffer.AllocLC();
        formField10->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField11 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin11));
    if (formField11)
        {
        TBuf<KBufSize> buffer;
        buffer.AppendNum(iLogEvent.Link(), KAppendFormat); // Link field
        HBufC* name = buffer.AllocLC();
        formField11->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField12 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin12));
    if (formField12)
        {
        TBuf<KBufSize> buffer;
        buffer.AppendNum(iLogEvent.Contact(), KAppendFormat); // Contact field
        HBufC* name = buffer.AllocLC();
        formField12->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField13 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin13));
    if (formField13)
        {
        HBufC* name = iLogEvent.Status().AllocLC(); // Status field
        formField13->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField14 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin14));
    if (formField14)
        {
        HBufC* name = iLogEvent.EventType().Name().AllocLC(); // EventType field
        formField14->SetTextL(name);
        CleanupStack::PopAndDestroy(name);
        }

    CEikEdwin* formField15 = static_cast <CEikEdwin*> (ControlOrNull(ELogExFormDlgCtrlIdEdwin15));
    if (formField15)
        {
        // This conversion is done just to show the data field for the user 
        // if there is anything
        if (iLogEvent.Data()!= KNullDesC8)
            {
            TBuf8<KBufSize> name8 = iLogEvent.Data(); // Data field
            TBuf16<KBufSize> name16;
            name8.Copy(name16);
            HBufC* name = name16.AllocLC();
            formField15->SetTextL(name);
            CleanupStack::PopAndDestroy(name);
            }
        else
            {
            TBuf<KBufSize> nodata;
            nodata.Copy(KNoData);
            HBufC* name = nodata.AllocLC();
            formField15->SetTextL(name);
            CleanupStack::PopAndDestroy(name);
            }
        }
    }

// ----------------------------------------------------------------------------
// Converts UTC time to local time. Implemented only for 3rd Edition platform.
// ----------------------------------------------------------------------------
#ifdef __SERIES60_3X__
void CLogExEventForm::UTCToLocalTimeL(TTime& aTime)
    {
    RTz tzServer;
    User::LeaveIfError(tzServer.Connect());
    CleanupClosePushL(tzServer);

    CTzConverter* tzConverter = CTzConverter::NewL(tzServer);
    CleanupStack::PushL(tzConverter);

    tzConverter->ConvertToLocalTime(aTime);

    CleanupStack::PopAndDestroy(2);
    }
#endif
//End of file

⌨️ 快捷键说明

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