datasourcemodules/defaultpositioningmodule/src/epos_cpospsylisthandler.cpp
changeset 0 9cfd9a3ee49c
child 52 29dbbeac905d
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "epos_cpospsylisthandler.h"
       
    20 #include "epos_cpossingletonmanager.h"
       
    21 #include "epos_cpospsyfixstatemanager.h"
       
    22 #include "epos_defaultproxyprivatecrkeys.h"
       
    23 #include "epos_cposconstmanager.h"
       
    24 #include "epos_defaultproxycommon.h"
       
    25 
       
    26 #include <lbs/epos_cposmodules.h>
       
    27 #include <lbs/epos_cposmoduleidlist.h>
       
    28 #include <centralrepository.h>
       
    29 
       
    30 
       
    31 // ================= MEMBER FUNCTIONS =======================
       
    32 
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 //
       
    36 CPosPsyListHandler::CPosPsyListHandler()
       
    37     {
       
    38     }
       
    39 
       
    40 // EPOC default constructor can leave.
       
    41 void CPosPsyListHandler::ConstructL()
       
    42     {
       
    43     TRACESTRING( "CPosPsyListHandler::ConstructL start... " )
       
    44 
       
    45     iFixStateManager = CPosPsyFixStateManager::GetInstanceL();
       
    46     iFixStateManager->AddListenerL( this );
       
    47     
       
    48     iConstManager = CPosConstManager::GetInstanceL();
       
    49 
       
    50     TRACESTRING( "CPosPsyListHandler::ConstructL end " )
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CPosPsyListHandler::GetInstanceL
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 CPosPsyListHandler* CPosPsyListHandler::GetInstanceL()
       
    58     {
       
    59     CPosPsyListHandler* self = reinterpret_cast < CPosPsyListHandler* > 
       
    60         ( CPosSingletonManager::GetObject( 
       
    61             EPosSigletonObjectIdPsyListHandlerId ) );
       
    62         
       
    63     if ( !self )
       
    64         {
       
    65         //Construct a new object and store it to CPosSingletonManager
       
    66         self = new ( ELeave ) CPosPsyListHandler;
       
    67         CleanupStack::PushL(self);
       
    68         self->ConstructL();
       
    69         CPosSingletonManager::SetObjectL(
       
    70             self,
       
    71             EPosSigletonObjectIdPsyListHandlerId );
       
    72         CleanupStack::Pop(self);
       
    73         }
       
    74         
       
    75     self->iRefCount++;
       
    76     
       
    77     return self;
       
    78     }
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CPosPsyListHandler::ReleaseInstance
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 void CPosPsyListHandler::ReleaseInstance()
       
    85     {
       
    86     iRefCount--;
       
    87     if ( iRefCount == 0 )
       
    88         {
       
    89         //We shall delete the instance
       
    90         CPosSingletonManager::ReleaseObject(
       
    91             EPosSigletonObjectIdPsyListHandlerId );
       
    92         }
       
    93     }
       
    94 
       
    95 // Destructor
       
    96 CPosPsyListHandler::~CPosPsyListHandler()
       
    97     {
       
    98     TRACESTRING( "CPosPsyListHandler::destructor start... " )
       
    99 
       
   100     if ( iConstManager )
       
   101         {
       
   102         iConstManager->ReleaseInstance();
       
   103         }
       
   104         
       
   105     if ( iFixStateManager )
       
   106         {
       
   107         iFixStateManager->RemoveListener( this );
       
   108         iFixStateManager->ReleaseInstance();
       
   109         }
       
   110     
       
   111     if ( iModulesSettings )
       
   112         {
       
   113         iModulesSettings->RemoveListener( *this );
       
   114         }
       
   115     
       
   116     iModuleInfoArray.Close();
       
   117 
       
   118     iListenerArray.Close();
       
   119     TRACESTRING( "CPosPsyListHandler::destructor end" )
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // CPosPsyListHandler::SetModuleSettingsManagerL
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 void CPosPsyListHandler::SetModuleSettingsManagerL(
       
   127             MPosModuleSettingsManager& aManager )
       
   128     {
       
   129     if ( iModulesSettings == NULL )
       
   130         {
       
   131         iModulesSettings = &aManager;
       
   132         iModulesSettings->AddListenerL( *this );
       
   133 
       
   134         UpdateModuleListL();
       
   135 
       
   136         //Move last working GPS PSY to the front of the list
       
   137         MovePsyToTop( iConstManager->GetLastWorkingGpsPsyId() );
       
   138         }
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------
       
   142 // CPosPsyListHandler::AddListenerL
       
   143 // ---------------------------------------------------------
       
   144 //
       
   145 void CPosPsyListHandler::AddListenerL(
       
   146             MPosPsyListListener* aListener )
       
   147     {
       
   148     User::LeaveIfError( iListenerArray.Append( aListener ) );
       
   149     }
       
   150             
       
   151 // ---------------------------------------------------------
       
   152 // CPosPsyListHandler::RemoveListener
       
   153 // ---------------------------------------------------------
       
   154 //
       
   155 void CPosPsyListHandler::RemoveListener(
       
   156             MPosPsyListListener* aListener )
       
   157     {
       
   158     TInt count = iListenerArray.Count();
       
   159     for ( TInt i = count -1; i >= 0; i-- )
       
   160         {
       
   161         if ( iListenerArray[i] == aListener )
       
   162             {
       
   163             iListenerArray.Remove( i );
       
   164             }
       
   165         }
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------
       
   169 // CPosPsyListHandler::GetPsyListL
       
   170 // ---------------------------------------------------------
       
   171 //
       
   172 void CPosPsyListHandler::GetPsyListL(
       
   173             RArray< TPositionModuleId >& aPsyList )
       
   174     {
       
   175     TRACESTRING( "CPosPsyListHandler::GetPsyListL" )
       
   176     aPsyList.Reset();
       
   177 
       
   178     TBool integratedGpsAdded = EFalse;
       
   179     
       
   180     TInt count = iModuleInfoArray.Count();
       
   181     for( TInt i = 0; i < count; i++ )
       
   182         {
       
   183         const TPositionModuleInfo& moduleInfo = iModuleInfoArray[i];
       
   184         if( moduleInfo.IsAvailable() )
       
   185             {
       
   186             if ( IsGpsTechnology( moduleInfo ) && 
       
   187                 moduleInfo.DeviceLocation() == TPositionModuleInfo::EDeviceInternal )
       
   188                 {
       
   189                 if ( !integratedGpsAdded )
       
   190                     {
       
   191                     TRACESTRING2( "PSY: %x", moduleInfo.ModuleId() )
       
   192                     aPsyList.Append( moduleInfo.ModuleId() );
       
   193                     integratedGpsAdded = ETrue;
       
   194                     }
       
   195                 }
       
   196             else
       
   197                 {
       
   198                 TRACESTRING2( "PSY: %x", moduleInfo.ModuleId() )
       
   199                 aPsyList.Append( moduleInfo.ModuleId() );
       
   200                 }
       
   201             }
       
   202         }
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------
       
   206 // CPosPsyListHandler::GetExtGpsPsyListL
       
   207 // ---------------------------------------------------------
       
   208 //
       
   209 void CPosPsyListHandler::GetExtGpsPsyListL(
       
   210         RArray< TPositionModuleId >& aPsyList )
       
   211     {
       
   212     TRACESTRING( "CPosPsyListHandler::GetExtGpsPsyListL" )
       
   213 
       
   214     aPsyList.Reset();
       
   215     
       
   216     TInt count = iModuleInfoArray.Count();
       
   217     for( TInt i = 0; i < count; i++ )
       
   218         {
       
   219         const TPositionModuleInfo& moduleInfo = iModuleInfoArray[i];
       
   220         if( moduleInfo.IsAvailable() && 
       
   221             IsGpsTechnology( moduleInfo ) && 
       
   222             moduleInfo.DeviceLocation() == TPositionModuleInfo::EDeviceExternal )
       
   223             {
       
   224             TRACESTRING2( "PSY: %x", moduleInfo.ModuleId() )
       
   225             aPsyList.Append( moduleInfo.ModuleId() );
       
   226             }
       
   227         }
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------
       
   231 // CPosPsyListHandler::IsClassSupported
       
   232 // ---------------------------------------------------------
       
   233 //
       
   234 TBool CPosPsyListHandler::IsClassSupported(
       
   235             TUint32 aClassType,
       
   236             TPositionModuleId aModuleId ) const
       
   237     {
       
   238     TInt index = ModuleIndex( aModuleId );
       
   239     if ( index != KErrNotFound )
       
   240         {
       
   241         const TPositionModuleInfo& moduleInfo = iModuleInfoArray[index];
       
   242         
       
   243         TUint32 classesSupported =
       
   244                 moduleInfo.ClassesSupported(EPositionInfoFamily);
       
   245 
       
   246         return ( aClassType == ( aClassType & classesSupported ) ) &&
       
   247                         ( aClassType & EPositionInfoClass );
       
   248         }
       
   249     return EFalse;
       
   250     }
       
   251 
       
   252 // ---------------------------------------------------------
       
   253 // CPosPsyListHandler::PsyFixStateChanged
       
   254 // ---------------------------------------------------------
       
   255 //
       
   256 void CPosPsyListHandler::PsyFixStateChanged( 
       
   257             TPositionModuleId aModuleId,
       
   258             CPosPsyFixStateManager::TPsyFixState aFixState )
       
   259     {
       
   260     TRACESTRING( "CPosPsyListHandler::PsyFixStateChanged start..." )
       
   261     TRACESTRING2( "PSY: %x", aModuleId )
       
   262     TRACESTRING2( "Fix state: %d", aFixState )
       
   263 
       
   264     TInt index = ModuleIndex( aModuleId );
       
   265     
       
   266     if ( index != KErrNotFound )
       
   267 	    {
       
   268     	TPositionModuleInfo moduleInfo = iModuleInfoArray[index];
       
   269 	    
       
   270 	    if ( IsGpsTechnology( moduleInfo ) && 
       
   271 	        aFixState == CPosPsyFixStateManager::EPsyFixStateYes )
       
   272 	        {
       
   273 	        //Move this one to the top of the list if it's not 
       
   274 	        //already on top
       
   275 	        TBool isListModified = MovePsyToTop( aModuleId );
       
   276 	        
       
   277 	        //If the list is modified, notify listeners
       
   278 	        if ( isListModified )
       
   279 	            {
       
   280 	            //Write last working GPS PSY UID to CenRep
       
   281 	            iConstManager->SetLastWorkingGpsPsyId( aModuleId );
       
   282 	            
       
   283 	            TPosPsyListChangeEvent event;
       
   284 	            event.iType = EPosPsyListChangeEventPriorityChanged;
       
   285 	            NotifyListeners( event );
       
   286 	            }
       
   287 	        }
       
   288     	}
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------
       
   292 // CPosPsyListHandler::HandleModuleSettingsChangedL
       
   293 // ---------------------------------------------------------
       
   294 //
       
   295 void CPosPsyListHandler::HandleModuleSettingsChangedL(
       
   296             TPosModulesEvent aEvent )
       
   297     {
       
   298     TRACESTRING( "CPosPsyListHandler::HandleModuleSettingsChagnedL start..." )
       
   299     TRACESTRING2( "Event type: %x", aEvent.iType )
       
   300     TRACESTRING2( "PSY: %x", aEvent.iModuleId )
       
   301 
       
   302     TInt index = ModuleIndex(aEvent.iModuleId);
       
   303     TPosPsyListChangeEvent event;
       
   304 
       
   305     switch (aEvent.iType)
       
   306         {
       
   307         case EPosModulesEventModuleRemoved:
       
   308             {
       
   309             //Remove module from the array
       
   310             if ( index != KErrNotFound )
       
   311                 {
       
   312                 iModuleInfoArray.Remove( index );
       
   313                 //notify listener module removed
       
   314                 event.iType = EPosPsyListChangeEventPsyDeleted;
       
   315                 event.iPsyId = aEvent.iModuleId;
       
   316                 NotifyListeners( event );
       
   317                 }
       
   318             }
       
   319             break;
       
   320         case EPosModulesEventAvailabilityChanged:
       
   321             {
       
   322             //Get new module info
       
   323             TPositionModuleInfo moduleInfo;
       
   324             iModulesSettings->GetModuleInfoL( 
       
   325                 aEvent.iModuleId, 
       
   326                 moduleInfo );
       
   327                 
       
   328             TBool isModuleAvailable = moduleInfo.IsAvailable();
       
   329             
       
   330             //Update the list
       
   331             UpdateModuleListL();
       
   332             
       
   333             if ( !isModuleAvailable )
       
   334                 {
       
   335                 //Module is disabled. 
       
   336                 //notify listener module removed
       
   337                 event.iType = EPosPsyListChangeEventPsyDeleted;
       
   338                 event.iPsyId = aEvent.iModuleId;
       
   339                 NotifyListeners( event );
       
   340                 }
       
   341             else
       
   342                 {
       
   343                 //If module is enabled. Current location request
       
   344                 //will not be affected. We only notify listeners
       
   345                 //to rebuild the PSY list
       
   346                 event.iType = EPosPsyListChangeEventListRebuild;
       
   347                 event.iPsyId = aEvent.iModuleId;
       
   348                 NotifyListeners( event );
       
   349                 }
       
   350             }
       
   351             break;
       
   352         case EPosModulesEventVisibilityChanged:
       
   353             {
       
   354             TBool isModuleVisible = iModulesSettings->IsModuleVisibleL(
       
   355                 aEvent.iModuleId );
       
   356 
       
   357             //Update the list
       
   358             UpdateModuleListL();
       
   359             
       
   360             if ( !isModuleVisible )
       
   361                 {
       
   362                 //Module is becoming invisible. 
       
   363                 //notify listener module removed
       
   364                 event.iType = EPosPsyListChangeEventPsyDeleted;
       
   365                 event.iPsyId = aEvent.iModuleId;
       
   366                 NotifyListeners( event );
       
   367                 }
       
   368             else
       
   369                 {
       
   370                 //If module is becoming visible. Current location request
       
   371                 //will not be affected. We only notify listeners
       
   372                 //to rebuild the PSY list
       
   373                 event.iType = EPosPsyListChangeEventListRebuild;
       
   374                 event.iPsyId = aEvent.iModuleId;
       
   375                 NotifyListeners( event );
       
   376                 }
       
   377             }
       
   378             break;
       
   379         case EPosModulesEventPrioritiesChanged:
       
   380         case EPosModulesEventModuleInstalled:
       
   381         case EPosModulesEventUnspecified:
       
   382             {
       
   383             UpdateModuleListL();
       
   384             event.iType = EPosPsyListChangeEventListRebuild;
       
   385             NotifyListeners( event );
       
   386             }
       
   387             break;
       
   388         default:
       
   389             //Other change has no effect on default proxy
       
   390             break;
       
   391         }
       
   392     }
       
   393 
       
   394 // ---------------------------------------------------------
       
   395 // CPosPsyListHandler::UpdateModuleListL
       
   396 // ---------------------------------------------------------
       
   397 //
       
   398 void CPosPsyListHandler::UpdateModuleListL()
       
   399     {
       
   400     TRACESTRING( "CPosPsyListHandler::UpdateModuleListL start..." )
       
   401 
       
   402 
       
   403     iModuleInfoArray.Reset();
       
   404     
       
   405     TInt index;
       
   406     
       
   407     // Read Module Info from settings and fill array
       
   408     CPosModuleIdList* idList = iModulesSettings->ModuleIdListL();
       
   409     CleanupStack::PushL( idList );
       
   410 
       
   411     TInt count = idList->Count();
       
   412     
       
   413     for ( index = 0; index < count; index++ )
       
   414         {
       
   415         TPositionModuleInfo moduleInfo;
       
   416 
       
   417         iModulesSettings->GetModuleInfoL( ( *idList )[index], moduleInfo );
       
   418 
       
   419         User::LeaveIfError( iModuleInfoArray.Append( moduleInfo ) );
       
   420         TRACESTRING2( "PSY: %x", moduleInfo.ModuleId() )
       
   421         }
       
   422 
       
   423     CleanupStack::PopAndDestroy(idList);
       
   424 
       
   425     /*
       
   426     iModuleInfoArray.Reset();
       
   427     
       
   428     TInt index;
       
   429     
       
   430     // Read Module Info from settings and fill array
       
   431     CPosModuleIdList* idList = iModulesSettings->ModuleIdListL();
       
   432     CleanupStack::PushL( idList );
       
   433 
       
   434     TInt count = idList->Count();
       
   435     
       
   436     TBool integratedGpsAdded = EFalse;
       
   437     
       
   438     for ( index = 0; index < count; index++ )
       
   439         {
       
   440         TPositionModuleInfo moduleInfo;
       
   441 
       
   442         iModulesSettings->GetModuleInfoL( ( *idList )[index], moduleInfo );
       
   443 
       
   444         //only one internal GPS PSY sppears in the list
       
   445         if ( IsGpsTechnology( moduleInfo ) && 
       
   446             moduleInfo.DeviceLocation() == TPositionModuleInfo::EDeviceInternal )
       
   447             {
       
   448             if ( !integratedGpsAdded )
       
   449                 {
       
   450                 User::LeaveIfError( iModuleInfoArray.Append( moduleInfo ) );
       
   451                 integratedGpsAdded = ETrue;
       
   452                 TRACESTRING2( "PSY: %x", moduleInfo.ModuleId() )
       
   453                 }
       
   454             }
       
   455         else
       
   456             {
       
   457             User::LeaveIfError( iModuleInfoArray.Append( moduleInfo ) );
       
   458             TRACESTRING2( "PSY: %x", moduleInfo.ModuleId() )
       
   459             }
       
   460         }
       
   461 
       
   462     CleanupStack::PopAndDestroy(idList);
       
   463     */
       
   464     }
       
   465 
       
   466 // ---------------------------------------------------------
       
   467 // CPosPsyListHandler::ModuleIndex
       
   468 // ---------------------------------------------------------
       
   469 //
       
   470 TInt CPosPsyListHandler::ModuleIndex( TPositionModuleId aModuleId ) const
       
   471     {
       
   472     TInt count = iModuleInfoArray.Count();
       
   473     for ( TInt i = 0; i < count; i++ )
       
   474         {
       
   475         const TPositionModuleInfo& moduleInfo = iModuleInfoArray[i];
       
   476         if( moduleInfo.ModuleId() == aModuleId )
       
   477             {
       
   478             return i;
       
   479             }
       
   480         }
       
   481     return KErrNotFound;
       
   482     }
       
   483 
       
   484 // ---------------------------------------------------------
       
   485 // CPosPsyListHandler::NotifyListeners
       
   486 // ---------------------------------------------------------
       
   487 //
       
   488 void CPosPsyListHandler::NotifyListeners( 
       
   489             const TPosPsyListChangeEvent& aEvent )
       
   490     {
       
   491     TInt count = iListenerArray.Count();
       
   492     for ( TInt i = 0; i < count; i++ )
       
   493         {
       
   494         iListenerArray[i]->PsyListChanged( aEvent );
       
   495         }
       
   496     }
       
   497     
       
   498 // ---------------------------------------------------------
       
   499 // CPosPsyListHandler::GetTtffAndTtnf
       
   500 // ---------------------------------------------------------
       
   501 //
       
   502 TInt CPosPsyListHandler::GetTtffAndTtnf(
       
   503             TPositionModuleId aModuleId,
       
   504             TTimeIntervalMicroSeconds& aTtff,
       
   505             TTimeIntervalMicroSeconds& aTtnf ) const
       
   506     {
       
   507     TInt index = ModuleIndex( aModuleId );
       
   508     if ( index != KErrNotFound )
       
   509         {
       
   510         const TPositionModuleInfo& moduleInfo = iModuleInfoArray[index];
       
   511         TPositionQuality quality;
       
   512         moduleInfo.GetPositionQuality( quality );
       
   513         
       
   514         aTtff = quality.TimeToFirstFix();
       
   515         aTtnf = quality.TimeToNextFix();
       
   516 
       
   517         TRACESTRING2( "Module Id: %x", aModuleId )
       
   518         TRACESTRING2( "TTFF: %d", aTtff.Int64() )
       
   519         TRACESTRING2( "TTNF: %d", aTtnf.Int64() )
       
   520 
       
   521         return KErrNone;
       
   522         }
       
   523     return KErrNotFound;
       
   524     }
       
   525 
       
   526 // ---------------------------------------------------------
       
   527 // CPosPsyListHandler::IsGpsTechnology
       
   528 // ---------------------------------------------------------
       
   529 //
       
   530 TBool CPosPsyListHandler::IsGpsTechnology( 
       
   531             const TPositionModuleInfo& aModuleInfo ) const
       
   532     {
       
   533     //When the module support satellite info, it is a type GPS technolgy
       
   534     TUint32 classesSupported =
       
   535         aModuleInfo.ClassesSupported(EPositionInfoFamily);
       
   536 
       
   537     return ( classesSupported & EPositionSatelliteInfoClass );
       
   538     }
       
   539 
       
   540 // ---------------------------------------------------------
       
   541 // CPosPsyListHandler::IsFirstGpsPsyExternal
       
   542 // ---------------------------------------------------------
       
   543 //
       
   544 TBool CPosPsyListHandler::IsFirstGpsPsyExternal() const
       
   545     {
       
   546     TInt count = iModuleInfoArray.Count();
       
   547     for( TInt i = 0; i < count; i++ )
       
   548         {
       
   549         const TPositionModuleInfo& moduleInfo = iModuleInfoArray[i];
       
   550         if( moduleInfo.IsAvailable() && 
       
   551             IsGpsTechnology( moduleInfo ) )
       
   552             {
       
   553             if ( moduleInfo.DeviceLocation() == TPositionModuleInfo::EDeviceExternal )
       
   554                 {
       
   555                 return ETrue;
       
   556                 }
       
   557             else
       
   558                 {
       
   559                 return EFalse;
       
   560                 }
       
   561             }
       
   562         }
       
   563     return ETrue;
       
   564     }
       
   565 
       
   566 // ---------------------------------------------------------
       
   567 // CPosPsyListHandler::IsModuleNetworkBased
       
   568 // ---------------------------------------------------------
       
   569 //
       
   570 TBool CPosPsyListHandler::IsModuleNetworkBased(
       
   571     TPositionModuleId aModuleId ) const
       
   572     {
       
   573     TInt index = ModuleIndex( aModuleId );
       
   574     
       
   575     if ( index != KErrNotFound )
       
   576         {
       
   577         const TPositionModuleInfo& moduleInfo = iModuleInfoArray[index];
       
   578         return ( moduleInfo.TechnologyType() & 
       
   579             TPositionModuleInfo::ETechnologyNetwork );
       
   580         }
       
   581         
       
   582     return EFalse;
       
   583     }
       
   584 
       
   585 
       
   586 // ---------------------------------------------------------
       
   587 // CPosPsyListHandler::MovePsyToTop
       
   588 // ---------------------------------------------------------
       
   589 //
       
   590 TBool CPosPsyListHandler::MovePsyToTop( TPositionModuleId aId )
       
   591     {
       
   592     if ( aId == KPositionNullModuleId )
       
   593         {
       
   594         return EFalse;
       
   595         }
       
   596         
       
   597     TInt index = ModuleIndex( aId );
       
   598     if ( index == KErrNotFound )
       
   599         {
       
   600         return EFalse;
       
   601         }
       
   602         
       
   603     TRACESTRING2( "MovePsyToTop: Id: %x", aId)
       
   604     
       
   605     TPositionModuleInfo moduleInfo = iModuleInfoArray[index];
       
   606         
       
   607     TBool isFirstSwitch = ETrue;
       
   608     
       
   609     TInt count = iModuleInfoArray.Count();
       
   610     for ( TInt i = 0; i < count; i++ )
       
   611         {
       
   612         TPositionModuleInfo info = iModuleInfoArray[i];
       
   613         if ( IsGpsTechnology( info ) )
       
   614             {
       
   615             if ( isFirstSwitch )
       
   616                 {
       
   617                 if( info.ModuleId() == aId || 
       
   618                     ( moduleInfo.DeviceLocation() == 
       
   619                         TPositionModuleInfo::EDeviceInternal &&
       
   620                       info.DeviceLocation() == 
       
   621                         TPositionModuleInfo::EDeviceExternal &&
       
   622                      iFixStateManager->GetPsyFixState(
       
   623                          info.ModuleId() ) == 
       
   624                          CPosPsyFixStateManager::EPsyFixStateYes ) )
       
   625                     {
       
   626                     //We dont move in this case.
       
   627                     return EFalse;
       
   628                     }
       
   629                       
       
   630                 }
       
   631             //switch
       
   632             iModuleInfoArray[i] = moduleInfo;
       
   633             moduleInfo = info;
       
   634             isFirstSwitch = EFalse;
       
   635             if( moduleInfo.ModuleId() == aId )
       
   636                 {
       
   637                 return ETrue;
       
   638                 }
       
   639             }
       
   640         }
       
   641     return ETrue;
       
   642     }
       
   643 
       
   644 //  End of File