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

📄 clocationexamplepositionrequestor.cpp

📁 Symbian Demo, why do you want to get 20 bytes.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        // There is no last known position
        case KErrUnknown:
            {
            // Send event to position listener
            HBufC* text = CEikonEnv::Static()->AllocReadResourceAsDes16LC(R_POSITION_UNKNOWN_TEXT);
            iPositionListener.MessageL(*text);
            CleanupStack::PopAndDestroy(text); 

            if ( iGettingLastknownPosition )
                {
                //Change the data class type
                iPosInfoBase = &iSatelliteInfo;

                //Mark that we are not requesting NotifyPositionUpdate
                iGettingLastknownPosition = EFalse;
                }

            // Request next position
            iPositioner.NotifyPositionUpdate( *iPosInfoBase, iStatus );

            // Set this object active
            SetActive();
            break;
            }
        // Unrecoverable errors.
        default:
            {
            // Send error to position listener
            buffer.Format(KLbsErrLocRequest, iStatus.Int());
            iPositionListener.ErrorL( buffer );
            break;
            }
        }

         //We are not going to query the last known position anymore.
        if ( iGettingLastknownPosition )
            {
            //Mark that we are not requesting NotifyPositionUpdate
            iGettingLastknownPosition = EFalse;
            }
    }


// -----------------------------------------------------------------------------
// CLocationExamplePositionRequestor::DoInitialiseL
// Initialises position server and positioner and
// begins the position request sequence.
// -----------------------------------------------------------------------------
//
void CLocationExamplePositionRequestor::DoInitialiseL()
    {
    // Connect to the position server
    TInt error = iPosServer.Connect( );
    TBuf<KErrBuffer> buffer;
    
    // The connection failed
    if ( KErrNone != error )
        {
        // Show error to the user and leave
        buffer.Format(KLbsErrPosServConn, error);
        iPositionListener.ErrorL( buffer );
        return;
        }

    // Open subsession to the position server
    error = iPositioner.Open(iPosServer);

    // The opening of a subsession failed
    if ( KErrNone != error )
        {
        // Show error to the user and leave
        buffer.Format(KLbsErrOpenPos, error);
        iPositionListener.ErrorL( buffer );
        iPosServer.Close();
        return;
        }

    // Set position requestor
    error = iPositioner.SetRequestor( CRequestor::ERequestorService ,
         CRequestor::EFormatApplication , KRequestor );

    // The requestor could not be set
    if ( KErrNone != error )
        {
        // Show error to the user and leave

        buffer.Format(KLbsErrSetRequestor, error);
        iPositionListener.ErrorL( buffer );
        iPositioner.Close();
        iPosServer.Close();
        return;
        }

    // Set update options
    error =  iPositioner.SetUpdateOptions( iUpdateops );

    // The options could not be updated
    if ( KErrNone != error  )
        {
        // Show error to the user and leave
        buffer.Format(KLbsErrSetUpOpt, error);
        iPositionListener.ErrorL( buffer );
        iPositioner.Close();
        iPosServer.Close();
        return;
        }

    // Get last known position. The processing of the result
    // is done in RunL method
    iPositioner.GetLastKnownPosition(*iPosInfoBase,iStatus);

    // Set this active object active
    SetActive();
    }

// -----------------------------------------------------------------------------
// CLocationExamplePositionRequestor::RunError
// -----------------------------------------------------------------------------
//
TInt CLocationExamplePositionRequestor::RunError(TInt /*aError*/)
    {
    return KErrNone;
    }

// -----------------------------------------------------------------------------
// CLocationExamplePositionRequestor::Continue
// -----------------------------------------------------------------------------
//
void CLocationExamplePositionRequestor::Pause()
    {
    if (IsActive())
        {
        Cancel();
        }
    }

// -----------------------------------------------------------------------------
// CLocationExamplePositionRequestor::Continue
// -----------------------------------------------------------------------------
//
void CLocationExamplePositionRequestor::Continue()
    {
    if (!IsActive())
        {
        // Get last known position. The processing of the result
        // is done in RunL method
        iPositioner.GetLastKnownPosition(*iPosInfoBase,iStatus);

        // Set this active object active
        SetActive();
        }
    }

// -----------------------------------------------------------------------------
// CLocationExamplePositionRequestor::GetCurrentPosition
// -----------------------------------------------------------------------------
//
TPositionInfoBase* CLocationExamplePositionRequestor::CurrentPosition()
    {
    return iPosInfoBase;    
    }

// -----------------------------------------------------------------------------
// CLocationExamplePositionRequestor::PositionUpdatedL
// Pre process the position information
// -----------------------------------------------------------------------------
//
void CLocationExamplePositionRequestor::PositionUpdatedL()
    {
    //If we are getting the last known position
    if ( iGettingLastknownPosition )
        {
        // Send position information to registered listener
        iPositionListener.PositionUpdatedL(*iPosInfoBase);

        //Change the data class type
        iPosInfoBase = &iSatelliteInfo;

        // Request next position
        iPositioner.NotifyPositionUpdate( *iPosInfoBase, iStatus );

        // Set this object active
        SetActive();
        }
    else
        {
        // Check if the id of the used PSY is 0
        if ( 0 == iUsedPsy.iUid)
            {
            // Set the id of the currently used PSY
            iUsedPsy = iPosInfoBase->ModuleId();
            }
        // Check if the position module has changed
        else if ( iPosInfoBase->ModuleId() != iUsedPsy )
            {
            // Set the id of the currently used PSY
            iUsedPsy = iPosInfoBase->ModuleId();

            //Position module info of new module
            TPositionModuleInfo moduleInfo;

            // Get module info
            iPosServer.GetModuleInfoById(iUsedPsy,moduleInfo);

            // Get classes supported
            TInt32 moduleInfoFamily = moduleInfo.ClassesSupported(EPositionInfoFamily);

            iPosInfoBase = &iSatelliteInfo;

            // Check if the new module supports
            // TPositionSatelliteInfo class
            if ( EPositionSatelliteInfoClass & moduleInfoFamily )
                {
                // Set info base to satellite info
                iPosInfoBase = &iSatelliteInfo;
                }
            // The position module must support atleast
            // TPositionInfo class
            else
                {
                // Set info base to position info
                iPosInfoBase = &iPositionInfo;
                }
            }

        // Send position information to registered listener
        iPositionListener.PositionUpdatedL(*iPosInfoBase);

        // Request next position
        iPositioner.NotifyPositionUpdate( *iPosInfoBase, iStatus );

        // Set this object active
        SetActive();
        }
    }

//  End of File

⌨️ 快捷键说明

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