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

📄 logexengine.cpp

📁 专业的用于查询手机通话记录的代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Sets recent events observer
// ----------------------------------------------------
//	
void CLogExEngine::SetRecentObserver(MEventsObserver* aObserver)
    {
    iRecentObserver = aObserver;
    }

// ----------------------------------------------------
// CLogExEngine::RemoveRecentObserver()
// Removes current resent events observer
// ----------------------------------------------------
//	
void CLogExEngine::RemoveRecentObserver()
    {
    iRecentObserver = NULL;
    }

// ----------------------------------------------------
// CLogExEngine::SetEventFilterDirectionIncoming()
// Sets incoming events filtering
// ----------------------------------------------------
//
void CLogExEngine::SetEventFilterDirectionIncoming()
    {
    TBuf<KLogMaxDirectionLength> direction;
    iLogClient->GetString(direction, R_LOG_DIR_IN);
    ClearEventFilter();
    iLogFilter->SetDirection(direction);
    }

// ----------------------------------------------------
// CLogExEngine::SetEventFilterDirectionOutgoing()
// Sets outgoing events filtering
// ----------------------------------------------------
//
void CLogExEngine::SetEventFilterDirectionOutgoing()
    {
    TBuf<KLogMaxDirectionLength> direction;
    iLogClient->GetString(direction, R_LOG_DIR_OUT);
    ClearEventFilter();
    iLogFilter->SetDirection(direction);
    }

// ----------------------------------------------------
// CLogExEngine::SetEventFilterEventTypeVoice()
// Sets voice type events filtering
// ----------------------------------------------------
//
void CLogExEngine::SetEventFilterEventTypeVoice()
    {
    ClearEventFilter();
    iLogFilter->SetEventType(KLogCallEventTypeUid);
    }

// ----------------------------------------------------
// CLogExEngine::SetEventFilterEventTypeSMS()
// Sets sms events filtering
// ----------------------------------------------------
//
void CLogExEngine::SetEventFilterEventTypeSMS()
    {
    ClearEventFilter();
    iLogFilter->SetEventType(KLogShortMessageEventTypeUid);
    }

// ----------------------------------------------------
// CLogExEngine::ClearEventFilter()
// Clears filter
// ----------------------------------------------------
//
void CLogExEngine::ClearEventFilter()
    {
    // Empty the active filter copying empty filter to it	
    iLogFilter->Copy(*iEmptyLogFilter);
    }

// ----------------------------------------------------
// CLogExEngine::ReadEventsL()
// Reads events from main event database
// ----------------------------------------------------
//
void CLogExEngine::ReadEventsL()
    {
    Cancel();

    // ETrue if there are any events in the log view
    if (iLogViewEvent->SetFilterL(*iLogFilter, iStatus))
        {
        // set this active object active to get the events 
        // from the main event database, see RunL()
        iTask = EGetEvent;
        SetActive();
        }
    // If there are no events in the main event database, 
    // do nothing and return
    }

// ----------------------------------------------------
// CLogExEngine::ReadRecentEventsL()
// Reads recents events from main event database
// ----------------------------------------------------
//
void CLogExEngine::ReadRecentEventsL()
    {
    Cancel();

    // ETrue if there are any events in the log view
    if (iLogViewRecent->SetRecentListL(KLogNullRecentList, iStatus))
        {
        // set this active object active to get the events 
        // from the main event database, see RunL()
        iTask = EGetRecent;
        SetActive();
        }
    // If there are no events in the main event database, 
    // do nothing and return
    }

// ----------------------------------------------------
// CLogExEngine::AddRandomEventL()
// Adds random event to log engine database
// ----------------------------------------------------
//
void CLogExEngine::AddRandomEventL()
    {
    Cancel();

    __ASSERT_ALWAYS( (iLogEvent == 0), User::Panic(KEngineAddRandomText,1) );

    iLogEvent = CreateRandomLogEventL(); // create new random log event

    iTask = EAddEvent; // tell RunL to add the iLogEvent to the log engine database
    iLogClient->AddEvent(*iLogEvent, iStatus); // call asynchronous method to add the event

    SetActive();
    }

// ----------------------------------------------------
// CLogExEngine::AddEventTypeToLogEngineL()
// Adds own event to main event database
// ----------------------------------------------------
//
void CLogExEngine::AddEventTypeToLogEngineL()
    {
    if (iOwnEvenTypeRegistered) // if already registered, do nothing and return
        {
        return;
        }

    Cancel(); // possible requests pending
    iTask = EAddEventType; // set task type for RunL

    iLogEventType = OwnLogEventTypeL(); // create new event type

    // register new event type the main event database
    iLogClient->AddEventType(*iLogEventType, iStatus);

    SetActive();
    }

// ----------------------------------------------------
// CLogExEngine::AddOwnEventL()
// Adds own event to the log engine database
// ----------------------------------------------------
//
void CLogExEngine::AddOwnEventL()
    {
    Cancel();

    if (!iOwnEvenTypeRegistered)
        {
        AddEventTypeToLogEngineL();
        return;
        }

    __ASSERT_ALWAYS( (iLogEvent == 0), User::Panic(KEngineAddOwnText,1) );

    iLogEvent = CreateRandomLogEventL(); // create a new random log event

    // change information and Uid
    // Own eventtypes TUids must be different from those defined
    // in logeng.h. They also don't show up in the Log application. 
    iLogEvent->SetEventType(KOwnEventTypeUid);

    // Set own information for the event

    iLogEvent->SetDescription(KOwnEventDescription);
    iLogEvent->SetDirection(KOwnEventDirection);
    iLogEvent->SetNumber(KOwnEventNumber);

    iTask = EAddEvent; // tell RunL to add the iLogEvent to the log engine database
    iLogClient->AddEvent(*iLogEvent, iStatus); // call asynchronous method to add the event

    SetActive();
    }

// ----------------------------------------------------
// CLogExEngine::OwnLogEventTypeL()
// This is to demonstrate how to build up an own event type.
// ----------------------------------------------------
//
CLogEventType* CLogExEngine::OwnLogEventTypeL()
    {
    CLogEventType* owneventtype = CLogEventType::NewL();

    // Event type spesific TUid must be set 	
    const TUid KOwnEventTypeUid =
        {
                0x10005570
        };

    owneventtype->SetUid(KOwnEventTypeUid);
    owneventtype->SetDescription(KOwnEventDescription);

    // Make sure event type is logged
    owneventtype->SetLoggingEnabled(ETrue);

    return owneventtype;
    }

// ----------------------------------------------------
// CLogExEngine::CreateRandomLogEventL()
// creates a random new log event for emulator
// ----------------------------------------------------
//
CLogEvent* CLogExEngine::CreateRandomLogEventL()
    {
    CLogEvent* event = CLogEvent::NewL();

    // Sets the duration of the event in seconds.
    // Randomize something between 0-299 
    event->SetDuration(Random(300));

    TBuf<KLogMaxDirectionLength> direction;

    // Direction of the event is randomized
    TInt randomDirection = Random(2); // randomize direction
    TInt dirID = 0;

    switch (randomDirection)
        {
        case 0:
            dirID = R_LOG_DIR_IN;
            break;
        case 1:
            dirID = R_LOG_DIR_OUT;
            break;
        default:
            break;
        }

    // Human readable presentations of directions
    // with CLogClient::GetString()-method

    iLogClient->GetString(direction, dirID);

    // Set the direction

    event->SetDirection(direction);

    // randomize event type from 6 different types
    TInt randomEventType = Random(6);

    TUid eventTypeID = KLogCallEventTypeUid;

    switch (randomEventType)
        {
        case 0:
            eventTypeID = KLogCallEventTypeUid; //Voice call
            break;
        case 1:
            eventTypeID = KLogDataEventTypeUid; // Data call
            break;
        case 2:
            eventTypeID = KLogFaxEventTypeUid; // Fax call
            break;
        case 3:
            eventTypeID = KLogShortMessageEventTypeUid; // SMS call
            break;
        case 4:
            eventTypeID = KLogMailEventTypeUid; // Email
            break;
        case 5:
            eventTypeID = KLogTaskSchedulerEventTypeUid; // Task scheduler event
            break;
        default:
            User::Panic(KEngineDefaultSwitch, 1);
            break;
        }

    event->SetEventType(eventTypeID);

    event->SetSubject(KOwnEventSubject);

    TTime time;
    time.UniversalTime(); // creation time as UTC
    event->SetTime(time);

    TBuf<KLogMaxNumberLength> number; // Randomize number
    number.AppendNum(Random(7000000));
    event->SetNumber(number);

    event->SetRemoteParty(KOwnEventRemoteParty);

    return event;
    }

// ----------------------------------------------------
// CLogExEngine::Random(const TInt& aLimiter)
// Creates random number
// ----------------------------------------------------
//
TInt CLogExEngine::Random(const TInt& aLimiter)
    {
    TTime time;
    time.HomeTime();
    TInt64 smallRandSeed=time.Int64();
    TInt number = Math::Rand(smallRandSeed)%aLimiter;
    return number;
    }

//End of file

⌨️ 快捷键说明

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