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

📄 hwrmtestappappui.cpp

📁 平台symbian。 功能:获取系统信息。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    dlg = CAknNumberQueryDialog::NewL( duration );
    
    //KHWRMVibraMinIntensity, KHWRMVibraMaxIntensity, 5 ;
    if( dlg->ExecuteLD( R_HWRMTESTAPP_DURATION_QUERY ) )
        {
        // got duration so now optionally get the intensity
        dlg = CAknNumberQueryDialog::NewL( intensity );
        //KHWRMVibraMinIntensity, KHWRMVibraMaxIntensity, 5 ;
        if( dlg->ExecuteLD( R_HWRMTESTAPP_VIBRA_INTENSITY_QUERY ) )
            {
            // got the intenstity
            _LIT(KStartVibraL, "StartVibraL(duration=%d,intensity=%d)");
            buf.Format( KStartVibraL, duration, intensity );
            iAppContainer->AddMessageL( buf );
            iVibra->StartVibraL( duration, intensity );
            }
        else
            {
            // user pressed cancel for intensity query
            _LIT(KStartVibraLDuration, "StartVibraL(duration=%d)");
            buf.Format( KStartVibraLDuration, duration );
            iAppContainer->AddMessageL( buf );
            iVibra->StartVibraL( duration );
            }
        }
    else
        {
        // user pressed cancel for duration query
        // do nothing...
        _LIT(KStartVibraLNotCalled, "StartVibraL not called!");
        iAppContainer->AddMessageL( KStartVibraLNotCalled );
        }
    }

// -----------------------------------------------------------------------------
// CHWRMTestAppAppUi::VibraStopL
// Stop vibra
// -----------------------------------------------------------------------------
//
void CHWRMTestAppAppUi::VibraStopL()
    {
    _LIT(KStopVibraLCalled, "StopVibraL called");
    iAppContainer->AddMessageL( KStopVibraLCalled );
    iVibra->StopVibraL();
    }

// -----------------------------------------------------------------------------
// CHWRMTestAppAppUi::VibraSettings
// Retrieve vibra settings
// -----------------------------------------------------------------------------
//
void CHWRMTestAppAppUi::VibraSettings()
    {
    VibraModeChanged( iVibra->VibraSettings() );
    }

// -----------------------------------------------------------------------------
// CHWRMTestAppAppUi::VibraStatus
// Retrieve vibra status
// -----------------------------------------------------------------------------
//
void CHWRMTestAppAppUi::VibraStatus()
    {
    VibraStatusChanged( iVibra->VibraStatus() );
    }


// =============================================================================
//                          LIGHTS RELATED METHODS
// =============================================================================

// -----------------------------------------------------------------------------
// CHWRMTestAppAppUi::LightsReserveL
// Reserve lights
// -----------------------------------------------------------------------------
//
void CHWRMTestAppAppUi::LightsReserveL()
    {
    TInt item(0);
    TBuf<100> buf;
    TBool restore;
    TBool forceNoCCoeEnv;
    TInt target(CHWRMLight::ENoTarget);
    
    // Get the lights target
    target = GetLightsTargetL();
    
    if( target == KErrCancel )
        {
        // no target entered
        _LIT(KReserveLightLNotCalled, "ReserveLightL not called, no target!");
        iAppContainer->AddMessageL( KReserveLightLNotCalled );
        return;
        }
    
    CAknListQueryDialog* listDlg = new (ELeave)CAknListQueryDialog( &item );
    
    if( listDlg->ExecuteLD(R_HWRMTESTAPP_RESTORE_LIST) )
        {
        // got restore state parameter
        item == 0 ? restore = EFalse : restore = ETrue;
        //now get force no CCoeEnv parameter
        listDlg = new (ELeave)CAknListQueryDialog( &item );
        if( listDlg->ExecuteLD(R_HWRMTESTAPP_NOCCOEENV_LIST) )
            {
            // got ForceNoCCoeEnv parameter
            item == 0 ? forceNoCCoeEnv = EFalse : forceNoCCoeEnv = ETrue;
            _LIT(KReserveLightL, "ReserveLightL(target=%d,restore=%d,forceNoCCoeEnv=%d)");
            buf.Format( KReserveLightL, target, restore, forceNoCCoeEnv );
            iAppContainer->AddMessageL( buf );
            iLight->ReserveLightL( target, restore, forceNoCCoeEnv );
            }
        else
            {
            // did not get ForceNoCCoeEnv parameter
            _LIT(KReserveLightLNotCalled, "ReserveLightL not called, no ForceNoCCoeEnv value");
            iAppContainer->AddMessageL( KReserveLightLNotCalled );
            }
        }
    else
        {
        // did not get restore parameter
        _LIT(KReserveLightLTarget, "ReserveLightL(target=%d)");
        buf.Format( KReserveLightLTarget, target );
        iAppContainer->AddMessageL( buf );
        iLight->ReserveLightL( target );
        }

    }
    
// -----------------------------------------------------------------------------
// CHWRMTestAppAppUi::LightsReleaseL
// Release lights
// -----------------------------------------------------------------------------
//
void CHWRMTestAppAppUi::LightsReleaseL()
    {
    TBuf<100> buf;
    TInt target(CHWRMLight::ENoTarget);
    
    // Get the lights target
    target = GetLightsTargetL();
    
    if( target == KErrCancel )
        {
        // no target entered
        _LIT(KReleaseLightNotCalled, "ReleaseLight not called, no target!");
        iAppContainer->AddMessageL( KReleaseLightNotCalled );
        }
    else
        {
        _LIT(KReleaseLight, "ReleaseLight(target=%d)");
        buf.Format( KReleaseLight, target );
        iAppContainer->AddMessageL( buf );
        iLight->ReleaseLight( target );
        }
    }

// -----------------------------------------------------------------------------
// CHWRMTestAppAppUi::LightsOnL
// Turn lights on
// -----------------------------------------------------------------------------
//
void CHWRMTestAppAppUi::LightsOnL()
    {
    TInt item(0);
    TInt duration(0);
    TInt intensity(0);
    TInt target(CHWRMLight::ENoTarget);
    TBool fade(EFalse);
    TBuf<100> buf;
    
    // Get the lights target
    target = GetLightsTargetL();
    
    if( target == KErrCancel )
        {
        // no target entered
        _LIT(KLightOnLNotCalled, "LightOnL not called, no target!");
        iAppContainer->AddMessageL( KLightOnLNotCalled );
        return;
        }
    
    //duration
    CAknNumberQueryDialog* queryDlg = CAknNumberQueryDialog::NewL( duration );
    if( queryDlg->ExecuteLD( R_HWRMTESTAPP_DURATION_QUERY ) )
        {
        // got duration so get intensity
        queryDlg = CAknNumberQueryDialog::NewL( intensity );
        if( queryDlg->ExecuteLD( R_HWRMTESTAPP_LIGHT_INTENSITY_QUERY ) )
            {
            // got the intenstity
            CAknListQueryDialog* listDlg = new (ELeave)CAknListQueryDialog( &item );
            if( listDlg->ExecuteLD(R_HWRMTESTAPP_FADE_LIST) )
                {
                // got fade parameter
                item == 0 ? fade = EFalse : fade = ETrue;
                _LIT(KLightOnLParameters, "LightOnL(target=%d,duration=%d,intensity=%d,fade=%d)");
                buf.Format( KLightOnLParameters, target, duration, intensity, fade );
                iAppContainer->AddMessageL( buf );
                iLight->LightOnL( target, duration, intensity, fade );
                }
            else
                {
                // did not get fade parameter
                _LIT(KLightOnL, "LightOnL not called, no fade value!");
                iAppContainer->AddMessageL( KLightOnL );
                }
            }
        else
            {
            // user pressed cancel for intensity query
            _LIT(KLightOnLTargetDuration, "LightOnL(target=%d,duration=%d)");
            buf.Format( KLightOnLTargetDuration, target, duration );
            iAppContainer->AddMessageL( buf );
            iLight->LightOnL( target, duration );
            }        
        }
    else
        {
        // didn't get duration so call basic API
        _LIT(KLightOnLTarget, "LightOnL(target=%d)");
        buf.Format( KLightOnLTarget, target );
        iAppContainer->AddMessageL( buf );
        iLight->LightOnL( target );
        }
    }

// -----------------------------------------------------------------------------
// CHWRMTestAppAppUi::LightsBlinkL
// Blink lights
// -----------------------------------------------------------------------------
//
void CHWRMTestAppAppUi::LightsBlinkL()
    {
    TInt duration(0);
    TInt onDuration(0);
    TInt offDuration(0);
    TInt intensity(0);
    TBuf<100> buf;
    
    // Get the lights target
    TInt target = GetLightsTargetL();
    if( target == KErrCancel )
        {
        // no target entered
        _LIT(KLightsBlinkNotCalled, "LightsBlink not called, no target!");
        iAppContainer->AddMessageL( KLightsBlinkNotCalled );
        return;
        }
    
    // get duration
    CAknNumberQueryDialog* queryDlg = CAknNumberQueryDialog::NewL( duration );
    if( queryDlg->ExecuteLD( R_HWRMTESTAPP_DURATION_QUERY ) )
        {
        // got duration so get OnDuration
        queryDlg = CAknNumberQueryDialog::NewL( onDuration );
        CleanupStack::PushL( queryDlg );
        
        _LIT(KEnterONDuration, "Enter ON duration (0 to 2147482)");
        queryDlg->SetPromptL( KEnterONDuration );
        
        CleanupStack::Pop( queryDlg );
        if( queryDlg->ExecuteLD( R_HWRMTESTAPP_DURATION_QUERY ) )
            {
            // got OnDuration so get OffDuration
            queryDlg = CAknNumberQueryDialog::NewL( offDuration );
            CleanupStack::PushL( queryDlg );
            
            _LIT(KEnterOFFDuration, "Enter OFF duration (0 to 2147482)");
            queryDlg->SetPromptL( KEnterOFFDuration );
            
            CleanupStack::Pop( queryDlg );
            if( queryDlg->ExecuteLD( R_HWRMTESTAPP_DURATION_QUERY ) )
                {
                // got OffDuration so get intensity
                queryDlg = CAknNumberQueryDialog::NewL( intensity );
                if( queryDlg->ExecuteLD( R_HWRMTESTAPP_LIGHT_INTENSITY_QUERY ) )
                    {
                    // got the intenstity
                    _LIT(KLightBlinkLParameters, "LightBlinkL(target=%d,duration=%d,onDuration=%d,offDuration=%d,intensity=%d)");
                    buf.Format( KLightBlinkLParameters,target, duration, onDuration, offDuration, intensity );
                    iAppContainer->AddMessageL( buf );
                    iLight->LightBlinkL( target, duration, onDuration,
                                         offDuration, intensity );
                    }
                else
                    {
                    // user pressed cancel for intensity
                    _LIT(KLightBlinkLNoIntensity, "LightBlinkL not called, no intensity value!");
                    iAppContainer->AddMessageL( KLightBlinkLNoIntensity );
                    }
                
                }
            else
                {
                // user pressed cancel for OffDuration
                _LIT(KLightBlinkLNoOffDuration, "LightBlinkL not called, no offDuration value!");
                iAppContainer->AddMessageL( KLightBlinkLNoOffDuration );
                }
            }
        else
            {
            // user pressed cancel for OnDuration
            _LIT(KLightBlinkLTargetDuration, "LightBlinkL(target=%d,duration=%d)");
            buf.Format( KLightBlinkLTargetDuration, target, duration );
            iAppContainer->AddMessageL( buf );
            }
        }
    else
        {
        // user pressed cancel for Duration
        _LIT(KLightBlinkLTarget, "LightBlinkL(target=%d)");
        buf.Format( KLightBlinkLTarget, target );
        iAppContainer->AddMessageL( buf );
        }
    }

// -----------------------------------------------------------------------------
// CHWRMTestAppAppUi::LightsOffL
// Turn lights off
// -----------------------------------------------------------------------------
//
void CHWRMTestAppAppUi::LightsOffL()
    {
    TInt item(0);
    TInt duration(0);
    TInt target(CHWRMLight::ENoTarget);
    TBool fade(EFalse);
    TBuf<100> buf;
    
    // Get the lights target
    target = GetLightsTargetL();
    
    if( target == KErrCancel )
        {
        // no target entered
        _LIT(KLightsOffLNoTarget, "LightsOffL not called, no target!");
        iAppContainer->AddMessageL( KLightsOffLNoTarget );
        return;
        }
    
    //duration
    CAknNumberQueryDialog* queryDlg = CAknNumberQueryDialog::NewL( duration );
    if( queryDlg->ExecuteLD( R_HWRMTESTAPP_DURATION_QUERY ) )
        {
        // got duration so get fade
        CAknListQueryDialog* listDlg = new (ELeave)CAknListQueryDialog( &item );
        if( listDlg->ExecuteLD(R_HWRMTESTAPP_FADE_LIST) )
            {
            // got fade parameter
            item == 0 ? fade = EFalse : fade = ETrue;

⌨️ 快捷键说明

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