idlefw/plugins/devicestatus/src/ainetworkinfolistener.cpp
branchRCL_3
changeset 118 8baec10861af
parent 114 a5a39a295112
equal deleted inserted replaced
114:a5a39a295112 118:8baec10861af
    98     }
    98     }
    99 
    99 
   100 
   100 
   101 void CAiNetworkInfoListener::AddObserverL( MAiNetworkInfoObserver& aObserver )
   101 void CAiNetworkInfoListener::AddObserverL( MAiNetworkInfoObserver& aObserver )
   102     {
   102     {
   103 	//Removing observer doesn't remove slots from array, removed observers are only
   103     
   104 	//set to NULL. Reason for this is found out later on the code. Adding observer
   104     if ( iObservers.Find( &aObserver ) == KErrNotFound)
   105 	//first tries to find free slot, if it is not found, observer is appended to the
   105         {
   106 	//array.
   106         //Removing observer doesn't remove slots from array, removed observers are only
   107     TInt freeSlot = iObservers.Find( NULL );
   107         //set to NULL. Reason for this is found out later on the code. Adding observer
   108 
   108         //first tries to find free slot, if it is not found, observer is appended to the
   109     if( freeSlot == KErrNotFound )
   109         //array.
   110         {
   110         TInt freeSlot = iObservers.Find( NULL );
   111         User::LeaveIfError( iObservers.Append( &aObserver ) );
   111     
   112         }
   112         if( freeSlot == KErrNotFound )
   113     else
   113             {
   114         {
   114             User::LeaveIfError( iObservers.Append( &aObserver ) );
   115         User::LeaveIfError( iObservers.Insert( &aObserver, freeSlot ) );
   115             }
   116         }
   116         else
   117     }
   117             {
       
   118             User::LeaveIfError( iObservers.Insert( &aObserver, freeSlot ) );
       
   119             }
       
   120         }
       
   121    }
   118 
   122 
   119 void CAiNetworkInfoListener::RemoveObserver( MAiNetworkInfoObserver& aObserver )
   123 void CAiNetworkInfoListener::RemoveObserver( MAiNetworkInfoObserver& aObserver )
   120     {
   124     {
   121 	//Remove observer, removing is done by replacing it with NULL pointer.
   125     TInt slot = iObservers.Find( &aObserver );
   122     const TInt count( iObservers.Count() );
   126     
   123 
   127     if (slot != KErrNotFound )
   124     for( TInt i( 0 ); i < count; i++ )
   128         {
   125         {
   129         //Remove observer, removing is done by replacing it with NULL pointer.
   126         if( iObservers[i] == &aObserver )
   130         iObservers.Remove( slot );
   127             {
   131         iObservers.Insert( NULL, slot );
   128             //replace it with NULL
       
   129             iObservers.Remove( i );
       
   130             iObservers.Insert( NULL, i );
       
   131             break;
       
   132             }
       
   133         }
   132         }
   134     }
   133     }
   135 
   134 
   136 
   135 
   137 const TNWInfo& CAiNetworkInfoListener::NetworkInfo() const
   136 const TNWInfo& CAiNetworkInfoListener::NetworkInfo() const
   153     }
   152     }
   154 
   153 
   155 
   154 
   156 void CAiNetworkInfoListener::HandleNetworkMessage( const TNWMessages aMessage )
   155 void CAiNetworkInfoListener::HandleNetworkMessage( const TNWMessages aMessage )
   157     {
   156     {
   158     __PRINT(__DBG_FORMAT("XAI: Handle NW message %d"), aMessage );
   157     __PRINT(__DBG_FORMAT("XAI: CAiNetworkInfoListener > Handle NW message %d"), aMessage );
       
   158     
       
   159     __PRINT(__DBG_FORMAT("XAI: iInfo.iRegistrationStatus %d"), iInfo.iRegistrationStatus );
       
   160     __PRINT(__DBG_FORMAT("XAI: iInfo.iStatus %d"), iInfo.iStatus );
       
   161     __PRINT(__DBG_FORMAT("XAI: iInfo.iCountryCode %S"), &iInfo.iCountryCode );
       
   162     __PRINT(__DBG_FORMAT("XAI: iInfo.iNetworkId %S"), &iInfo.iNetworkId );
       
   163     __PRINT(__DBG_FORMAT("XAI: iInfo.iOperatorNameInfo.iType %d"), iInfo.iOperatorNameInfo.iType );
       
   164     __PRINT(__DBG_FORMAT("XAI: iInfo.iOperatorNameInfo.iName %S"), &iInfo.iOperatorNameInfo.iName );
       
   165     __PRINT(__DBG_FORMAT("XAI: iInfo.iDisplayTag %S"), &iInfo.iDisplayTag );
       
   166     __PRINT(__DBG_FORMAT("XAI: iInfo.iShortName %S"), &iInfo.iShortName );
       
   167     __PRINT(__DBG_FORMAT("XAI: iInfo.iLongName %S"), &iInfo.iLongName );
       
   168     __PRINT(__DBG_FORMAT("XAI: iInfo.iSPName %S"), &iInfo.iSPName );
       
   169     __PRINT(__DBG_FORMAT("XAI: iInfo.iServiceProviderNameDisplayReq %d"), iInfo.iServiceProviderNameDisplayReq );
       
   170     __PRINT(__DBG_FORMAT("XAI: iInfo.iNPName %S"), &iInfo.iNPName );
       
   171     __PRINT(__DBG_FORMAT("XAI: iInfo.iPLMNField %S"), &iInfo.iPLMNField );
       
   172     
   159     //Insert message into the message cache. Only one messsage of one type.
   173     //Insert message into the message cache. Only one messsage of one type.
   160     TRAPD( err, iMessageCache->InsertIsqL( aMessage, iKeyProperties ) );
   174     TRAPD( err, iMessageCache->InsertIsqL( aMessage, iKeyProperties ) );
   161     if( err == KErrAlreadyExists )
   175     if( err == KErrAlreadyExists )
   162         {
   176         {
       
   177         __PRINTS("XAI: message already exists in cache");
   163         err = KErrNone;
   178         err = KErrNone;
   164         }
   179         }
   165     if( err != KErrNone )
   180     if( err != KErrNone )
   166         {
   181         {
       
   182         __PRINTS("XAI: error inserting message to cache , return");
   167         return;
   183         return;
   168         }
   184         }
   169 
   185 
       
   186     __PRINTS("XAI: check if allowed to display operator indicator");
   170 	iShowOpInd 		= !NotAllowedToDisplayOperatorIndicator( aMessage );
   187 	iShowOpInd 		= !NotAllowedToDisplayOperatorIndicator( aMessage );
   171 
   188 
   172 	TBool hasNetInfoChanged = HasNetworkInfoChanged( aMessage );
   189 	TBool hasNetInfoChanged = HasNetworkInfoChanged( aMessage );
   173 	if ( !hasNetInfoChanged )
   190 	if ( !hasNetInfoChanged )
   174 		{
   191 		{
       
   192 	    __PRINTS("XAI: net info not changed, return");
   175 		return;
   193 		return;
   176 		}
   194 		}
       
   195 
   177 	__PRINT(__DBG_FORMAT("XAI: Show operator indicator %d, info changed %d"), iShowOpInd, hasNetInfoChanged );
   196 	__PRINT(__DBG_FORMAT("XAI: Show operator indicator %d, info changed %d"), iShowOpInd, hasNetInfoChanged );
   178     const TInt count( iObservers.Count() );
   197     const TInt count( iObservers.Count() );
   179 
   198 
   180 
   199 
   181     for( TInt i( 0 ); i < count; i++ )
   200     for( TInt i( 0 ); i < count; i++ )
   198     }
   217     }
   199 
   218 
   200 
   219 
   201 void CAiNetworkInfoListener::HandleNetworkError( const TNWOperation aOperation, TInt aErrorCode )
   220 void CAiNetworkInfoListener::HandleNetworkError( const TNWOperation aOperation, TInt aErrorCode )
   202     {
   221     {
   203     __PRINT(__DBG_FORMAT("XAI: Error code %d"), aErrorCode );
   222     __PRINT(__DBG_FORMAT("XAI: CAiNetworkInfoListener > NetworkError code %d"), aErrorCode );
   204 
   223 
   205     TNWMessages errorCode = TNWMessages( KErrGeneral );
   224     TNWMessages errorCode = TNWMessages( KErrGeneral );
   206 
   225 
   207     switch ( aOperation )
   226     switch ( aOperation )
   208         {
   227         {