connectionmonitoring/connmon/connectionmonitor/src/ConnMonIAP.cpp
changeset 53 4af712113915
parent 20 9c97ad6591ae
equal deleted inserted replaced
47:cb7afde124a3 53:4af712113915
     1 /*
     1 /*
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   419 // -----------------------------------------------------------------------------
   419 // -----------------------------------------------------------------------------
   420 //
   420 //
   421 TInt CConnMonIAP::EnumerateConnections( TUint& aCount )
   421 TInt CConnMonIAP::EnumerateConnections( TUint& aCount )
   422     {
   422     {
   423     // Server must be 'blocked' while updating the connection table.
   423     // Server must be 'blocked' while updating the connection table.
   424     TConnectionInfoBuf connInfoBuf;
       
   425     TBearerInfo bearerInfo;
   424     TBearerInfo bearerInfo;
   426     TConnInfo connInfo( 0, 0, 0, 0, bearerInfo );
   425     TConnInfo connInfo( 0, 0, 0, 0, bearerInfo );
   427     TInt err( KErrNone );
   426     TInt err( KErrNone );
   428 
   427 
   429     aCount = 0;
   428     aCount = 0;
  2310             delete iConnInfos[index].iConnAttach;
  2309             delete iConnInfos[index].iConnAttach;
  2311             iConnInfos[index].iConnAttach = NULL;
  2310             iConnInfos[index].iConnAttach = NULL;
  2312             }
  2311             }
  2313 
  2312 
  2314         iConnInfos.Remove( index );
  2313         iConnInfos.Remove( index );
       
  2314 
       
  2315         // If dial-up PDP context override feature is enabled and active (a dial-up
       
  2316         // connection is about to start), connection closures need to be reported
       
  2317         // in case dial-up connection is waiting for a free PDP context.
       
  2318         if ( iServer->GetDialUpOverrideStatus() == EConnMonDialUpOverrideActive )
       
  2319             {
       
  2320             if ( !ActivePacketdataConnectionsFound() )
       
  2321                 {
       
  2322                 iServer->ConnectionsClosedForDialUpOverride();
       
  2323                 }
       
  2324             }
       
  2325 
  2315         err = KErrNone;
  2326         err = KErrNone;
  2316         }
  2327         }
  2317 
  2328 
  2318     // Print connection info array to log
  2329     // Print connection info array to log
  2319     #ifdef _DEBUG
  2330     #ifdef _DEBUG
  2977 
  2988 
  2978 // -----------------------------------------------------------------------------------
  2989 // -----------------------------------------------------------------------------------
  2979 // CConnMonIAP::GetDeleteNotifyStatus
  2990 // CConnMonIAP::GetDeleteNotifyStatus
  2980 // -----------------------------------------------------------------------------------
  2991 // -----------------------------------------------------------------------------------
  2981 //
  2992 //
  2982 TInt CConnMonIAP::GetDeleteNotifyStatus( TConnInfo& aConnection, TBool& aSent )
  2993 TInt CConnMonIAP::GetDeleteNotifyStatus( TConnInfo& aConnection )
  2983     {
  2994     {
  2984     TInt index( KErrNotFound );
  2995     TInt index( KErrNotFound );
  2985 
  2996 
  2986     if ( aConnection.iBearer >= EBearerExternalCSD )
  2997     if ( aConnection.iBearer >= EBearerExternalCSD )
  2987         {
  2998         {
  2995         return KErrNotFound;
  3006         return KErrNotFound;
  2996         }
  3007         }
  2997 
  3008 
  2998     aConnection.iConnectionId = iConnInfos[index].iConnectionId;
  3009     aConnection.iConnectionId = iConnInfos[index].iConnectionId;
  2999     aConnection.iBearer = iConnInfos[index].iBearer;
  3010     aConnection.iBearer = iConnInfos[index].iBearer;
  3000 
       
  3001     TInt connectionStatus( 0 );
       
  3002     GetConnectionStatus( index, connectionStatus );
       
  3003 
       
  3004     if ( ( iConnInfos[index].iConnDownNotifier != 0 ) &&
       
  3005          ( iConnInfos[index].iProgressNotifier != 0 ) )
       
  3006         {
       
  3007         if ( !iConnInfos[index].iConnDownNotifier->DeleteSent() &&
       
  3008              !iConnInfos[index].iConnDownNotifier->IsActive() &&
       
  3009              ( !iConnInfos[index].iProgressNotifier->IsActive() ||
       
  3010                ( connectionStatus != KLinkLayerOpen ) ) )
       
  3011             {
       
  3012             aSent = EFalse;
       
  3013             }
       
  3014         else
       
  3015             {
       
  3016             aSent = ETrue;
       
  3017             }
       
  3018         }
       
  3019     else
       
  3020         {
       
  3021         aSent = EFalse;
       
  3022         }
       
  3023 
  3011 
  3024     return KErrNone;
  3012     return KErrNone;
  3025     }
  3013     }
  3026 
  3014 
  3027 // -----------------------------------------------------------------------------------
  3015 // -----------------------------------------------------------------------------------
  3351             }
  3339             }
  3352         }
  3340         }
  3353     //LOGEXITFN("CConnMonIAP::GetActiveConnectionsIds()")
  3341     //LOGEXITFN("CConnMonIAP::GetActiveConnectionsIds()")
  3354     }
  3342     }
  3355 
  3343 
       
  3344 // -----------------------------------------------------------------------------
       
  3345 // CConnMonIAP::ActivePacketdataConnectionsFound
       
  3346 // Return ETrue if one or more active packetdata connections are found,
       
  3347 // EFalse otherwise.
       
  3348 // -----------------------------------------------------------------------------
       
  3349 //
       
  3350 TBool CConnMonIAP::ActivePacketdataConnectionsFound()
       
  3351     {
       
  3352     LOGENTRFN("CConnMonIAP::ActivePacketdataConnectionsFound()")
       
  3353     TBool result( EFalse );
       
  3354     TInt unknownBearers( 0 );
       
  3355 
       
  3356     const TInt count = iConnInfos.Count();
       
  3357     for ( TInt i = 0; i < count; i++ )
       
  3358         {
       
  3359         // Bearer might still be uninitialized
       
  3360         if ( iConnInfos[i].iBearer == EBearerUnknown )
       
  3361             {
       
  3362             unknownBearers++;
       
  3363             }
       
  3364         else if ( iConnInfos[i].iBearer == EBearerGPRS ||
       
  3365                 iConnInfos[i].iBearer == EBearerEdgeGPRS ||
       
  3366                 iConnInfos[i].iBearer == EBearerWCDMA )
       
  3367             {
       
  3368             result = ETrue;
       
  3369             break;
       
  3370             }
       
  3371         }
       
  3372     if ( !result && unknownBearers )
       
  3373         {
       
  3374         for ( TInt i = 0; i < count; i++ )
       
  3375             {
       
  3376             if ( iConnInfos[i].iBearer == EBearerUnknown )
       
  3377                 {
       
  3378                 LOGIT1("ActivePacketdataConnectionsFound: bearer unknown for conn.id %d",
       
  3379                         iConnInfos[i].iConnectionId)
       
  3380                 TInt err = GetBearer(
       
  3381                         iConnInfos[i].iConnectionId,
       
  3382                         iConnInfos[i].iBearer,
       
  3383                         iConnInfos[i].iBearerInfo );
       
  3384 
       
  3385                 if ( err == KErrNone )
       
  3386                     {
       
  3387                     if ( iConnInfos[i].iBearer == EBearerGPRS ||
       
  3388                             iConnInfos[i].iBearer == EBearerEdgeGPRS ||
       
  3389                             iConnInfos[i].iBearer == EBearerWCDMA )
       
  3390                         {
       
  3391                         result = ETrue;
       
  3392                         break;
       
  3393                         }
       
  3394                     }
       
  3395                 }
       
  3396             }
       
  3397         }
       
  3398 
       
  3399     LOGEXITFN1("CConnMonIAP::ActivePacketdataConnectionsFound()", result)
       
  3400     return result;
       
  3401     }
  3356 
  3402 
  3357 // -----------------------------------------------------------------------------
  3403 // -----------------------------------------------------------------------------
  3358 // CConnMonIAP::GetBearerSupportInfo
  3404 // CConnMonIAP::GetBearerSupportInfo
  3359 // Checks whether the current cell and the phone support a bearer (GPRS or CSD).
  3405 // Checks whether the current cell and the phone support a bearer (GPRS or CSD).
  3360 // -----------------------------------------------------------------------------
  3406 // -----------------------------------------------------------------------------