connectionmonitoring/connectionmonitorui/src/ConnectionInfoBase.cpp
branchRCL_3
changeset 57 05bc53fe583b
parent 55 fc7b30ed2058
child 58 83ca720e2b9a
equal deleted inserted replaced
55:fc7b30ed2058 57:05bc53fe583b
     1 /*
       
     2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Represents a connection
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <stdlib.h>
       
    22 #include <nifvar.h>
       
    23 #include <StringLoader.h>
       
    24 #include <ConnectionMonitorUi.rsg>
       
    25 #include <avkon.rsg>
       
    26 #include <AknUtils.h>
       
    27 #include <apgcli.h>
       
    28 
       
    29 #include "ConnectionMonitorUiLogger.h"
       
    30 #include "ConnectionInfoBase.h"
       
    31 #include "ActiveWrapper.h"
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 const TUint KUpArrowChar = 0x2191; ///< ASCII code of UpArrow
       
    36 const TUint KDownArrowChar = 0x2193; ///< ASCII code of DownArrow
       
    37 
       
    38 #ifndef _DEBUG
       
    39 const TUint KHiddenDhcpServerUid = 0x101fd9c5; ///< Hidden DHCP server UID (dhcpserv.exe)
       
    40 const TUint KHiddenDnsServerUid = 0x10000882; ///< Hidden DNS server UID (dnd.exe)
       
    41 #endif
       
    42 
       
    43 const TInt KFeedsServerUid         = 0x1020728E;
       
    44 const TInt KDownloadMgrServerUid   = 0x10008D60;
       
    45 const TInt KMessagingServerUid     = 0x1000484b;
       
    46 const TInt KJavaVMUid              = 0x102033E6;
       
    47 const TInt KSUPLServerUid          = 0x102073CA;
       
    48 
       
    49 LOCAL_D const TInt KStringsGranularity = 5;
       
    50 
       
    51 _LIT( KMrouterName, "mRouter"); ///< see CheckMrouteIap
       
    52 _LIT( KEmpty, "");      ///< Empty string
       
    53 
       
    54 
       
    55 
       
    56 
       
    57 // ================= MEMBER FUNCTIONS =======================
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CConnectionInfoBase::~CConnectionInfoBase
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 CConnectionInfoBase::~CConnectionInfoBase()
       
    64     {
       
    65     delete iDetailsArray;
       
    66     delete iAppNames;
       
    67     }
       
    68 
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // CConnectionInfoBase::CConnectionInfoBase
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 CConnectionInfoBase::CConnectionInfoBase(
       
    75                            TInt aConnectionId,
       
    76                            RConnectionMonitor* const aConnectionMonitor,
       
    77                            TConnMonBearerType aConnectionBearerType,
       
    78                            CActiveWrapper* aActiveWrapper ) :
       
    79     iConnectionMonitor( aConnectionMonitor ), 
       
    80     iStartTime( NULL ),
       
    81     iLastSpeedUpdate( 0 ),
       
    82     iDeletedFromCMUI( EFalse ),
       
    83     iActiveWrapper( aActiveWrapper )
       
    84     {
       
    85     CMUILOGGER_WRITE( "CConnectionInfoBase constuctor - start " );
       
    86     iConnectionStatus = EConnectionUninitialized;
       
    87     iConnectionId = aConnectionId;
       
    88     iConnectionBearerType = aConnectionBearerType;
       
    89     iClientBuf().iCount = 0;
       
    90     CMUILOGGER_WRITE( "CConnectionInfoBase constuctor - end " );
       
    91     }
       
    92 
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CConnectionInfoBase::ConstructL
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CConnectionInfoBase::ConstructL()
       
    99     {
       
   100     CMUILOGGER_ENTERFN( "CConnectionInfoBase::ConstructL() start" );
       
   101 
       
   102     if ( iConnectionBearerType >= EBearerExternalCSD )
       
   103         {
       
   104         StringLoader::Load( iConnectionName,
       
   105                             R_QTN_CMON_ITEM_CONN_NAME_MODEM );
       
   106         }
       
   107     else
       
   108         {
       
   109         iActiveWrapper->StartGetStringAttribute( iConnectionId,
       
   110                                                  iConnectionMonitor,
       
   111                                                  KIAPName,
       
   112                                                  iConnectionName );
       
   113         TInt err( iActiveWrapper->iStatus.Int() );
       
   114         CMUILOGGER_WRITE_F( "CConnectionInfoBase::ConstructL() status: %d",
       
   115                             err );
       
   116         CMUILOGGER_WRITE_F( "iConnectionName : %S", &iConnectionName );
       
   117         CMUILOGGER_WRITE_F( "iConnectionId : %d", iConnectionId );
       
   118         CMUILOGGER_WRITE_F( "iConnectionBearerType : %d", 
       
   119                             ( TInt )iConnectionBearerType );
       
   120         if ( err != KErrNone )
       
   121             {
       
   122             User::Leave( err );
       
   123             }
       
   124         }
       
   125     
       
   126     if ( !iAppNames )
       
   127         {
       
   128         iAppNames = new( ELeave ) CDesCArrayFlat( KStringsGranularity );
       
   129         }
       
   130 
       
   131     StatusChangedL();
       
   132     if ( GetStatus() == EConnectionSuspended )
       
   133         {
       
   134         InitializeConnectionInfoL();
       
   135         }
       
   136     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::ConstructL() end" );
       
   137     }
       
   138 
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // CConnectionInfoBase::StatusChangedL
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 void CConnectionInfoBase::StatusChangedL()
       
   145     {
       
   146     CMUILOGGER_WRITE( "CConnectionInfoBase::StatusChangedL() start" );
       
   147 
       
   148     RefreshConnectionStatus();
       
   149 
       
   150     switch ( iConnectionStatus )
       
   151         {
       
   152         case EConnectionCreated:
       
   153             {
       
   154             InitializeConnectionInfoL();
       
   155             break;
       
   156             }
       
   157         case EConnectionSuspended:
       
   158             {
       
   159             RefreshDetailsL();
       
   160             if ( !iDetailsArray )
       
   161                 {
       
   162                 ToArrayDetailsL();
       
   163                 }
       
   164             RefreshDetailsArrayL();
       
   165             break;
       
   166             }
       
   167         case EConnectionClosing:
       
   168         case EConnectionClosed:
       
   169         case EConnectionUninitialized:
       
   170         	{
       
   171         	if ( iDetailsArray ) // if there is details array
       
   172         	    {
       
   173         	    RefreshDetailsArrayL();
       
   174         	    }
       
   175             break;
       
   176         	}
       
   177         case EConnectionCreating:
       
   178         default :
       
   179             {
       
   180             break;
       
   181             }
       
   182         }
       
   183 
       
   184     RefreshConnectionListBoxItemTextL();
       
   185 
       
   186     CMUILOGGER_WRITE( "CConnectionInfoBase::StatusChangedL() end" );
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------
       
   190 // CConnectionInfoBase::IsAlive
       
   191 // ---------------------------------------------------------
       
   192 //
       
   193 TBool CConnectionInfoBase::IsAlive() const
       
   194     {
       
   195     TBool alive( EFalse );
       
   196     if ( ( iConnectionStatus == EConnectionSuspended ) ||
       
   197          ( iConnectionStatus == EConnectionCreated ) )
       
   198         {
       
   199         alive = ETrue;
       
   200         }
       
   201     return alive;
       
   202     }
       
   203     
       
   204 // ---------------------------------------------------------
       
   205 // CConnectionInfoBase::IsSuspended
       
   206 // ---------------------------------------------------------
       
   207 //
       
   208 TBool CConnectionInfoBase::IsSuspended() const
       
   209     {
       
   210     TBool suspended( EFalse );
       
   211     if ( iConnectionStatus == EConnectionSuspended )
       
   212         {
       
   213         suspended = ETrue;
       
   214         }
       
   215     return suspended;
       
   216     }    
       
   217 
       
   218 // ---------------------------------------------------------
       
   219 // CConnectionInfoBase::GetConnectionId
       
   220 // ---------------------------------------------------------
       
   221 //
       
   222 CDesCArrayFlat* CConnectionInfoBase::GetDetailsArray() const
       
   223     {
       
   224     return iDetailsArray;
       
   225     }
       
   226 
       
   227 // ---------------------------------------------------------
       
   228 // CConnectionInfoBase::GetConnectionId
       
   229 // ---------------------------------------------------------
       
   230 //
       
   231 TUint CConnectionInfoBase::GetConnectionId() const
       
   232     {
       
   233     return iConnectionId;
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------
       
   237 // CConnectionInfoBase::GetStatus
       
   238 // ---------------------------------------------------------
       
   239 //
       
   240 TConnectionStatus CConnectionInfoBase::GetStatus() const
       
   241     {
       
   242     return iConnectionStatus;
       
   243     }
       
   244 
       
   245 // ---------------------------------------------------------
       
   246 // CConnectionInfoBase::GetName
       
   247 // ---------------------------------------------------------
       
   248 //
       
   249 HBufC* CConnectionInfoBase::GetNameLC() const
       
   250     {
       
   251     HBufC* name = iConnectionName.AllocLC();
       
   252     return name;
       
   253     }
       
   254 
       
   255 // ---------------------------------------------------------
       
   256 // CConnectionInfoBase::GetBearerType
       
   257 // ---------------------------------------------------------
       
   258 //
       
   259 TConnMonBearerType CConnectionInfoBase::GetBearerType() const
       
   260     {
       
   261     return iConnectionBearerType;
       
   262     }
       
   263 
       
   264 
       
   265 // ---------------------------------------------------------
       
   266 // CConnectionInfoBase::GetConnectionListBoxItemText
       
   267 // ---------------------------------------------------------
       
   268 //
       
   269 TPtrC CConnectionInfoBase::GetConnectionListBoxItemText() const
       
   270     {
       
   271     return iListBoxItemText;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------
       
   275 // CConnectionInfoBase::RefreshConnectionStatus
       
   276 // ---------------------------------------------------------
       
   277 //
       
   278 void CConnectionInfoBase::RefreshConnectionStatus()
       
   279     {
       
   280     TConnectionStatus connStatus( EConnectionUninitialized );
       
   281     iActiveWrapper->StartGetIntAttribute( iConnectionId,
       
   282                                           iConnectionMonitor,
       
   283                                           KConnectionStatus,
       
   284                                           ( ( TInt& )( connStatus ) ) );
       
   285     TInt err( iActiveWrapper->iStatus.Int() );
       
   286     CMUILOGGER_WRITE_F( "RefreshConnectionStatus status : %d",
       
   287                         err );
       
   288     if ( err == KErrNone )
       
   289         {
       
   290         RefreshConnectionStatus( connStatus );
       
   291         }
       
   292     else
       
   293         {
       
   294         iActiveWrapper->Cancel();
       
   295         }
       
   296     }
       
   297 
       
   298 // ---------------------------------------------------------
       
   299 // CConnectionInfoBase::RefreshConnectionStatus
       
   300 // ---------------------------------------------------------
       
   301 //
       
   302 void CConnectionInfoBase::RefreshConnectionStatus(
       
   303                                    const TInt aConnectionStatus )
       
   304     {
       
   305     CMUILOGGER_ENTERFN( "RefreshConnectionStatus" );
       
   306     CMUILOGGER_WRITE_F( "RefreshConnectionStatus aConnectionStatus %d",
       
   307                         ( TInt )aConnectionStatus );
       
   308     CMUILOGGER_WRITE_F( "iConnectionStatus before %d",
       
   309                         ( TInt )iConnectionStatus );
       
   310                         
       
   311 
       
   312     if ( ( aConnectionStatus == KLinkLayerOpen ) ||
       
   313           ( ( aConnectionStatus == KConnectionOpen ) &&
       
   314             ( iConnectionBearerType >= EBearerExternalCSD ) ) )
       
   315         {
       
   316         CMUILOGGER_WRITE("1");
       
   317         iConnectionStatus = EConnectionCreated;
       
   318         }
       
   319     else if ( ( aConnectionStatus == KConnectionClosed ) ||
       
   320               ( aConnectionStatus == KLinkLayerClosed ) ) 
       
   321         {
       
   322         CMUILOGGER_WRITE("2");        
       
   323         iConnectionStatus = EConnectionClosed;
       
   324         }
       
   325     else if ( ( ( aConnectionStatus >= KMinAgtProgress ) &&
       
   326                ( aConnectionStatus <= KConnectionOpen ) ) ||
       
   327                ( aConnectionStatus == KStartingSelection ) ||
       
   328                ( aConnectionStatus == KFinishedSelection ) ||
       
   329                ( aConnectionStatus == KConfigDaemonStartingRegistration ) ||
       
   330                ( aConnectionStatus == KConfigDaemonFinishedRegistration ) )
       
   331         // creating
       
   332         {
       
   333         CMUILOGGER_WRITE("5");
       
   334         iConnectionStatus = EConnectionCreating;
       
   335         }
       
   336     else if ( aConnectionStatus == KDataTransferTemporarilyBlocked )
       
   337         {
       
   338         CMUILOGGER_WRITE("6");
       
   339         iConnectionStatus = EConnectionSuspended;
       
   340         }
       
   341     else if ( ( iConnectionStatus == EConnectionCreated ) &&
       
   342               ( ( aConnectionStatus >= KConnectionStartingClose ) &&
       
   343                 ( aConnectionStatus < KConnectionClosed ) ||  
       
   344                 ( aConnectionStatus == KConfigDaemonFinishedDeregistrationStop ) || 
       
   345                 ( aConnectionStatus == KConfigDaemonStartingDeregistration ) ||
       
   346                 ( aConnectionStatus == KLinkLayerClosed ) ||
       
   347                 ( aConnectionStatus == KConnectionUninitialised )
       
   348               ) )
       
   349         // closing
       
   350         {
       
   351         CMUILOGGER_WRITE("7");        
       
   352         iConnectionStatus = EConnectionClosing;
       
   353         }
       
   354     else if ( ( aConnectionStatus == KConnectionUninitialised ) &&
       
   355              ( iConnectionStatus == EConnectionSuspended ) )
       
   356         { // Back to created from suspended
       
   357         CMUILOGGER_WRITE("4");
       
   358         iConnectionStatus = EConnectionCreated;
       
   359         }
       
   360     else if ( aConnectionStatus == KConnectionUninitialised )
       
   361         {
       
   362         CMUILOGGER_WRITE("3");
       
   363         iConnectionStatus = EConnectionUninitialized;
       
   364         }
       
   365         
       
   366     else
       
   367         {
       
   368         CMUILOGGER_WRITE_F( " else iConnectionStatus  %d",
       
   369                             ( TInt )iConnectionStatus );
       
   370         CMUILOGGER_WRITE_F( "else aConnectionStatus  %d",
       
   371                             ( TInt )aConnectionStatus );
       
   372         
       
   373         CMUILOGGER_WRITE("else");
       
   374         }
       
   375 
       
   376 
       
   377     CMUILOGGER_WRITE_F( "iConnectionStatus after %d",
       
   378                         ( TInt )iConnectionStatus );
       
   379     CMUILOGGER_LEAVEFN( "RefreshConnectionStatus" );                                                
       
   380     }
       
   381 
       
   382 
       
   383 // ---------------------------------------------------------
       
   384 // CConnectionInfoBase::RefreshSentReceivedDataL
       
   385 // ---------------------------------------------------------
       
   386 //
       
   387 void CConnectionInfoBase::RefreshSentReceivedDataL()
       
   388     {
       
   389     CMUILOGGER_ENTERFN( "CConnectionInfoBase::RefreshSentReceivedDataL" );
       
   390     // Downloaded
       
   391 	CMUILOGGER_WRITE("Downloaded before");
       
   392     iActiveWrapper->StartGetUintAttribute( iConnectionId,
       
   393                                            iConnectionMonitor,
       
   394                                            KDownlinkData,
       
   395                                            iDownloaded );
       
   396     TInt errDownload( iActiveWrapper->iStatus.Int() );
       
   397     CMUILOGGER_WRITE_F( "Download status: %d", errDownload );
       
   398     if ( errDownload != KErrNone )
       
   399         {
       
   400         iActiveWrapper->Cancel();
       
   401         User::Leave( errDownload );
       
   402         }
       
   403    	CMUILOGGER_WRITE("Downloaded after");
       
   404     // Uploaded
       
   405 	CMUILOGGER_WRITE("Uploaded before");
       
   406     iActiveWrapper->StartGetUintAttribute( iConnectionId,
       
   407                                            iConnectionMonitor,
       
   408                                            KUplinkData,
       
   409                                            iUploaded );
       
   410     TInt errUpload( iActiveWrapper->iStatus.Int() );
       
   411     CMUILOGGER_WRITE_F( "Upload status: %d", errUpload );
       
   412     if ( errUpload != KErrNone )
       
   413         {
       
   414         iActiveWrapper->Cancel();
       
   415         User::Leave( errUpload );
       
   416         }
       
   417 	CMUILOGGER_WRITE("Uploaded after");
       
   418 
       
   419     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::RefreshSentReceivedDataL" );
       
   420     }
       
   421 
       
   422 
       
   423 // ---------------------------------------------------------
       
   424 // CConnectionInfoBase::RefreshTransferSpeedsL
       
   425 // ---------------------------------------------------------
       
   426 //
       
   427 void CConnectionInfoBase::RefreshTransferSpeedsL()
       
   428     {
       
   429     CMUILOGGER_ENTERFN( "CConnectionInfoBase::RefreshTransferSpeedsL" );
       
   430     const TInt KUpdatingIntervalInMillisec = 500;
       
   431     const TInt KStandardKilo = 1000;
       
   432     const TInt KDataKilo = 1024;
       
   433     
       
   434     TUint up = iUploaded;
       
   435     TUint down = iDownloaded;
       
   436 
       
   437     RefreshSentReceivedDataL();
       
   438 
       
   439     TTime now;
       
   440     now.UniversalTime();
       
   441     
       
   442     // calculate time difference in milliseconds
       
   443     TInt diffTime = I64INT( now.MicroSecondsFrom( iLastSpeedUpdate ).Int64() / 
       
   444             TInt64( KStandardKilo ) );
       
   445 
       
   446     if ( iLastSpeedUpdate.Int64() == 0 )
       
   447         {
       
   448         iLastSpeedUpdate = now;
       
   449 
       
   450         // speed cannot be calculated at the first time
       
   451         iUpSpeed.quot = 0;
       
   452         iUpSpeed.rem = 0;
       
   453         iDownSpeed.quot = 0;
       
   454         iDownSpeed.rem = 0;
       
   455         }
       
   456     else if ( diffTime > KUpdatingIntervalInMillisec )         
       
   457         {
       
   458         // bytes/millisec
       
   459         TInt upSpeed = ( iUploaded - up ) / diffTime;
       
   460         TInt downSpeed = ( iDownloaded - down ) / diffTime;
       
   461         
       
   462         // bytes/sec       
       
   463         upSpeed *= KStandardKilo;
       
   464         downSpeed *= KStandardKilo;
       
   465     
       
   466         // kbytes/sec
       
   467         iUpSpeed = div( upSpeed, KDataKilo );
       
   468         iDownSpeed = div( downSpeed, KDataKilo );
       
   469 
       
   470         iLastSpeedUpdate = now;
       
   471         }
       
   472     
       
   473     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::RefreshTransferSpeedsL" );
       
   474     }
       
   475 
       
   476 
       
   477 // ---------------------------------------------------------
       
   478 // CConnectionInfoBase::RefreshDuration
       
   479 // ---------------------------------------------------------
       
   480 //
       
   481 void CConnectionInfoBase::RefreshDuration()
       
   482     {
       
   483     CMUILOGGER_ENTERFN( "CConnectionInfoBase::RefreshDuration" );
       
   484     TTime now;
       
   485     now.UniversalTime();
       
   486 
       
   487     // passed time since connection established.
       
   488     iDuration = now.MicroSecondsFrom( iStartTime ).Int64();
       
   489     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::RefreshDuration" );
       
   490     }
       
   491 
       
   492 
       
   493 // ---------------------------------------------------------
       
   494 // CConnectionInfoBase::RefreshAppNamesL
       
   495 // ---------------------------------------------------------
       
   496 //
       
   497 TInt CConnectionInfoBase::RefreshAppNamesL()
       
   498     {
       
   499     CMUILOGGER_ENTERFN( "CConnectionInfoBase::RefreshAppNamesL" );
       
   500 
       
   501     TInt sharings( 0 );
       
   502 
       
   503     if ( IsAlive() )
       
   504         {
       
   505         if ( iAppNames )
       
   506             {
       
   507             // Check whether it is an internal or external (modem) connection
       
   508             // External (modem) connections does not need application name
       
   509             if ( iConnectionBearerType >= EBearerExternalCSD )
       
   510                 {
       
   511                 CMUILOGGER_WRITE( "External (modem) connections does not need application name" );
       
   512                 return sharings;
       
   513                 }
       
   514             else
       
   515                 {
       
   516                 TInt count( 0 );
       
   517                 TConnMonClientEnumBuf clientBuf;
       
   518                 iActiveWrapper->StartGetConnSharings( iConnectionId,
       
   519                                                       iConnectionMonitor,
       
   520                                                       clientBuf );
       
   521 
       
   522                 TInt err( iActiveWrapper->iStatus.Int() );
       
   523                 CMUILOGGER_WRITE_F( "RefreshSharings status: %d", err );
       
   524 
       
   525                 if ( !err )
       
   526                     {
       
   527                     count = clientBuf().iCount;
       
   528                     }
       
   529                 CMUILOGGER_WRITE_F( "clientBuf().iCount: %d", count );
       
   530 
       
   531                 if ( IsTheSameUids( clientBuf ) )
       
   532                     {
       
   533                     // Same client list, use cached application names.
       
   534                     CMUILOGGER_WRITE( "Client list unchanged, use cached names" );
       
   535                     CMUILOGGER_WRITE_F( "sharings: %d", iAppNames->Count() );
       
   536                     return iAppNames->Count();
       
   537                     }
       
   538                 else
       
   539                     {
       
   540                     CMUILOGGER_WRITE( "Client list changed, update names" );
       
   541                     CopyUidsToBuf ( clientBuf );
       
   542                     }
       
   543 
       
   544                 iAppNames->Reset();
       
   545                 HBufC* actAppName = NULL;
       
   546 
       
   547 #ifndef __WINS__ // Appl. uid is always zero in emulator
       
   548 
       
   549                 RApaLsSession appSess;
       
   550                 TApaAppInfo appInfo;
       
   551 
       
   552                 // The connection could be shared by several applications
       
   553                 User::LeaveIfError( appSess.Connect() );
       
   554 
       
   555                 TUint i;
       
   556                 for ( i = 0; i < count; i++ )
       
   557                     {
       
   558                     actAppName = NULL;
       
   559                     appInfo.iCaption.Zero();
       
   560 
       
   561                     TInt result = appSess.GetAppInfo( appInfo,
       
   562                             clientBuf().iUid[i] );
       
   563 
       
   564                     //================================
       
   565                     CMUILOGGER_WRITE_F( "result: %d", result );
       
   566                     CMUILOGGER_WRITE_F( "iClientInfo.iUid[i].iUid: %x",
       
   567                             clientBuf().iUid[i].iUid );
       
   568 
       
   569                     if ( result != KErrNone )
       
   570                         {
       
   571                         TInt resId = 0;
       
   572                         switch ( clientBuf().iUid[i].iUid )
       
   573                             {
       
   574                             case KMessagingServerUid: // Messaging
       
   575                                 {
       
   576                                 resId = R_QTN_CMON_SHARING_APP_MSG_SERVER;
       
   577                                 break;
       
   578                                 }
       
   579                             case KDownloadMgrServerUid: // Downloads
       
   580                                 {
       
   581                                 resId = R_QTN_CMON_SHARING_APP_DL_MG;
       
   582                                 break;
       
   583                                 }
       
   584                             case KFeedsServerUid: // Web Feeds
       
   585                                 {
       
   586                                 resId = R_QTN_CMON_SHARING_APP_RSS_SERVER;
       
   587                                 break;
       
   588                                 }
       
   589                             case KJavaVMUid: // Application
       
   590                                 {
       
   591                                 resId = R_QTN_CMON_SHARING_APP_JAVA_MIDLET;
       
   592                                 break;
       
   593                                 }
       
   594 #ifndef _DEBUG
       
   595                             // Hide DHCP & DNS from UI in release build.
       
   596                             case KHiddenDhcpServerUid:
       
   597                             case KHiddenDnsServerUid:
       
   598                                 {
       
   599                                 break;
       
   600                                 }
       
   601 #endif
       
   602                             case KSUPLServerUid:
       
   603                                 {
       
   604                                 resId = R_QTN_CMON_SHARING_APP_SUPL;
       
   605                                 break;
       
   606                                 }
       
   607                             default: // (unknown)
       
   608                                 {
       
   609                                 resId = R_QTN_CMON_SHARING_APP_UNKNOWN;
       
   610                                 break;
       
   611                                 }
       
   612                             }
       
   613 
       
   614                         if ( resId && resId != R_QTN_CMON_SHARING_APP_UNKNOWN  )
       
   615                             {
       
   616                             actAppName = StringLoader::LoadL( resId );
       
   617                             }
       
   618                         else if ( resId ) // Try to find application process name from system.
       
   619                             {
       
   620                             TFileName name;
       
   621                             TFindProcess find;
       
   622                             TBool name_solved( EFalse );
       
   623                             while ( find.Next( name ) == KErrNone )
       
   624                                 {
       
   625                                 RProcess ph;
       
   626                                 TInt err2( KErrNone );
       
   627                                 err2 = ph.Open( name );
       
   628 
       
   629                                 if ( err2 )
       
   630                                     {
       
   631                                     ph.Close();
       
   632                                     }
       
   633                                 else
       
   634                                     {
       
   635                                     TUidType procUid = ph.Type();
       
   636                                     ph.Close();
       
   637 
       
   638                                     // There are three UIDs in procUid. The last one is the second
       
   639                                     // UID defined in MMP file and clientBuf().iUid[i].iUid is also
       
   640                                     // the same kind of UID. So, we only need to compare them to
       
   641                                     // find application name.
       
   642                                     if ( procUid[2].iUid == clientBuf().iUid[i].iUid )
       
   643                                         {
       
   644                                         // Name is in format "app_name[uid]001", so cut rest of
       
   645                                         // string starting from "[".
       
   646                                         TInt index = name.LocateReverse('[');
       
   647                                         if ( index >= 1 )
       
   648                                             {
       
   649                                             name.SetLength( index );
       
   650                                             }
       
   651 
       
   652                                         actAppName = HBufC::NewL( name.Length() );
       
   653                                         TPtr actAppNameBuf = actAppName->Des();
       
   654                                         actAppNameBuf.Append( name );
       
   655 
       
   656 #ifdef _DEBUG
       
   657                                         CMUILOGGER_WRITE( "--------------------" );
       
   658                                         CMUILOGGER_WRITE( " Application is Found:" );
       
   659                                         CMUILOGGER_WRITE_F( "Client Uid: %x", clientBuf().iUid[i].iUid );
       
   660                                         CMUILOGGER_WRITE_F( "Proc Uid: %x", procUid[2].iUid );
       
   661                                         CMUILOGGER_WRITE_F( "App Name: %S", &name);
       
   662                                         CMUILOGGER_WRITE( "--------------------" );
       
   663 #endif
       
   664 
       
   665                                         name_solved = ETrue;
       
   666                                         break;
       
   667                                         }
       
   668                                     }
       
   669                                 }
       
   670 
       
   671                             if ( !name_solved )
       
   672                                 {
       
   673                                 actAppName = StringLoader::LoadL( R_QTN_CMON_SHARING_APP_UNKNOWN );
       
   674                                 }
       
   675                             }
       
   676                         }
       
   677                     else
       
   678                         {
       
   679                         actAppName = HBufC::NewL( appInfo.iCaption.Length() );
       
   680                         TPtr actAppNameBuf = actAppName->Des();
       
   681                         actAppNameBuf.Append( appInfo.iCaption );
       
   682                         }
       
   683 
       
   684                     if ( actAppName )
       
   685                         {
       
   686                         iAppNames->AppendL( actAppName->Des() );
       
   687                         delete actAppName;
       
   688                         }
       
   689                     }
       
   690 
       
   691                 iAppNames->Sort();
       
   692                 appSess.Close();
       
   693 #else
       
   694                 TInt countBan( 0 );
       
   695 
       
   696 #ifndef _DEBUG
       
   697                 if ( !err )
       
   698                     {
       
   699                     // Remove DHCP and DNS from the client list. 
       
   700                     for ( TUint tmp = 0; tmp < count; tmp++ )
       
   701                         {
       
   702                         TUid uid = clientBuf().iUid[tmp];
       
   703 
       
   704                         if ( uid.iUid == KHiddenDhcpServerUid || uid.iUid == KHiddenDnsServerUid )
       
   705                             {
       
   706                             countBan++;
       
   707                             }
       
   708                         }
       
   709                     }
       
   710 #endif
       
   711 
       
   712                 _LIT( KStrApplication, "Application" );
       
   713                 // Give a dummy name for all applications.
       
   714                 for ( TInt i = 0; i < ( count - countBan ); i++ )
       
   715                     {
       
   716                     iAppNames->AppendL( KStrApplication );
       
   717                     }
       
   718 
       
   719 #endif // __WINS__
       
   720                 } // End of else in if ( iConnectionBearerType > EBearerExternalCSD )
       
   721             sharings = iAppNames->Count();
       
   722             CMUILOGGER_WRITE_F( "sharings: %d", sharings );
       
   723             } // End of if ( iAppNames )
       
   724         } // End of if ( IsAlive() )
       
   725 
       
   726     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::RefreshAppNamesL" );
       
   727     return sharings;
       
   728     }
       
   729 
       
   730 // ---------------------------------------------------------
       
   731 // CConnectionInfoBase::IsTheSameUids
       
   732 // ---------------------------------------------------------
       
   733 //
       
   734 TBool CConnectionInfoBase::IsTheSameUids( TConnMonClientEnumBuf& aClients )
       
   735     {
       
   736     TBool ret( EFalse );
       
   737 
       
   738     if ( iClientBuf().iCount != aClients().iCount )
       
   739         {
       
   740         return ret;
       
   741         }
       
   742     else
       
   743         {
       
   744         TInt count = aClients().iCount;
       
   745         for ( TInt i = 0; i < count; i++ )
       
   746             {
       
   747             // Is the current value inside aClients found from iClientBuf.
       
   748             TBool found( EFalse );
       
   749             for ( TInt j = 0; j < count; j++ )
       
   750                 {
       
   751                 if ( aClients().iUid[i].iUid == iClientBuf().iUid[j].iUid )
       
   752                     {
       
   753                     found = ETrue;
       
   754                     break;
       
   755                     }
       
   756                 }
       
   757 
       
   758             if ( !found )
       
   759                 {
       
   760                 return ret;
       
   761                 }
       
   762             }
       
   763 
       
   764         // If we reach this point, aClients contents are identical with iClientBuf.
       
   765         ret = ETrue;
       
   766         }
       
   767 
       
   768     return ret;
       
   769     }
       
   770 
       
   771 // ---------------------------------------------------------
       
   772 // CConnectionInfoBase::CopyUidsToBuf
       
   773 // ---------------------------------------------------------
       
   774 //
       
   775 void CConnectionInfoBase::CopyUidsToBuf( TConnMonClientEnumBuf& aClients )
       
   776     {
       
   777     TInt count = aClients().iCount;
       
   778 
       
   779     for ( TInt i = 0; i < count; i++ )
       
   780         {
       
   781         iClientBuf().iUid[i].iUid = aClients().iUid[i].iUid;
       
   782         }
       
   783     iClientBuf().iCount = count;
       
   784     }
       
   785 
       
   786 // ---------------------------------------------------------
       
   787 // CConnectionInfoBase::ToDetailsListBoxItemTextL
       
   788 // ---------------------------------------------------------
       
   789 //
       
   790 HBufC*  CConnectionInfoBase::ToDetailsListBoxItemTextL(
       
   791                                                 const TUint aResourceId,
       
   792                                                 const HBufC* aValueText ) const
       
   793     {
       
   794     CMUILOGGER_ENTERFN( "CConnectionInfoBase::ToDetailsListBoxItemTextL" );
       
   795 
       
   796     HBufC* columnName = NULL;
       
   797     if ( aResourceId )
       
   798         {
       
   799         columnName = StringLoader::LoadLC( aResourceId );
       
   800         }
       
   801     else
       
   802         {
       
   803         columnName = KEmpty().AllocLC();
       
   804         }
       
   805 
       
   806     HBufC* listBoxItemText = HBufC::NewL( KDetailsListItemText );
       
   807 
       
   808     TPtr ptrToListBoxItemText = listBoxItemText->Des();
       
   809 
       
   810     ptrToListBoxItemText.Format( KDetailsListItemTextFormat,
       
   811                                  columnName, aValueText );
       
   812     CleanupStack::PopAndDestroy( columnName );
       
   813 
       
   814 
       
   815     CMUILOGGER_LEAVEFN( "CConnectionInfoBase::ToDetailsListBoxItemTextL" );
       
   816 
       
   817     return listBoxItemText;
       
   818     }
       
   819 
       
   820 // ---------------------------------------------------------
       
   821 // CConnectionInfoBase::ToDetailsListBoxItemTextWithAppendL
       
   822 // ---------------------------------------------------------
       
   823 //
       
   824 void  CConnectionInfoBase::ToDetailsListBoxItemTextWithAppendL(
       
   825                                                 const TUint aResourceId,
       
   826                                                 const HBufC* aValueText )
       
   827     {
       
   828     HBufC* listBoxItemText = ToDetailsListBoxItemTextL( aResourceId,
       
   829                                                         aValueText );
       
   830     CleanupStack::PushL( listBoxItemText );
       
   831     CMUILOGGER_WRITE_F( "LISTBOXITEM: %S", listBoxItemText );
       
   832     iDetailsArray->AppendL( *listBoxItemText );
       
   833     CleanupStack::PopAndDestroy( listBoxItemText );
       
   834     }
       
   835 
       
   836 
       
   837 // ---------------------------------------------------------
       
   838 // CConnectionInfoBase::ToDetailsListBoxItemTextWithReplaceL
       
   839 // ---------------------------------------------------------
       
   840 //
       
   841 void  CConnectionInfoBase::ToDetailsListBoxItemTextWithReplaceL(
       
   842                                                     const TUint aResourceId,
       
   843                                                     const HBufC* aValueText,
       
   844                                                     TInt aIndex )
       
   845     {
       
   846     CMUILOGGER_ENTERFN
       
   847         ( "CConnectionInfoBase::ToDetailsListBoxItemTextWithReplaceL" );
       
   848     CMUILOGGER_WRITE_F( "aValueText: %S", aValueText );
       
   849 
       
   850     if ( /*( iDetailsArray ) && */
       
   851             ( aIndex < iDetailsArray->Count() ) &&
       
   852                 ( aIndex > KErrNotFound ) )
       
   853         {
       
   854         HBufC* listBoxItemText = ToDetailsListBoxItemTextL( aResourceId,
       
   855                                                             aValueText );
       
   856         iDetailsArray->Delete( aIndex );
       
   857         CleanupStack::PushL( listBoxItemText );
       
   858         iDetailsArray->InsertL( aIndex, *listBoxItemText );
       
   859         CleanupStack::PopAndDestroy( listBoxItemText );
       
   860         iDetailsArray->Compress();
       
   861         }
       
   862     CMUILOGGER_LEAVEFN
       
   863         ( "CConnectionInfoBase::ToDetailsListBoxItemTextWithReplaceL" );
       
   864 
       
   865     }
       
   866 
       
   867 // ---------------------------------------------------------
       
   868 // CConnectionInfoBase::ToStringBearerLC
       
   869 // ---------------------------------------------------------
       
   870 //
       
   871 HBufC* CConnectionInfoBase::ToStringBearerLC() const
       
   872     {
       
   873     HBufC* bearer = NULL;
       
   874     TUint resourceId( 0 );
       
   875 
       
   876     // Bearer type
       
   877     if ( iConnectionBearerType == EBearerHSCSD ||
       
   878         iConnectionBearerType == EBearerExternalHSCSD )
       
   879         {
       
   880         resourceId = R_QTN_CMON_BEARER_HSCSD;
       
   881 
       
   882         }
       
   883     else if ( iConnectionBearerType == EBearerCSD ||
       
   884              iConnectionBearerType == EBearerExternalCSD ||
       
   885              iConnectionBearerType == EBearerWcdmaCSD ||
       
   886              iConnectionBearerType == EBearerExternalWcdmaCSD )
       
   887         {
       
   888         resourceId = R_QTN_SET_BEARER_DATA_CALL;
       
   889         }
       
   890     else if ( iConnectionBearerType == EBearerWLAN )
       
   891         {
       
   892         resourceId = R_QTN_WLAN_SETT_BEARER_WLAN;
       
   893         }
       
   894     else
       
   895         {
       
   896         resourceId = R_QTN_SET_BEARER_PACKET_DATA;
       
   897         }
       
   898 
       
   899     bearer = StringLoader::LoadLC( resourceId );
       
   900 
       
   901     return bearer;
       
   902     }
       
   903 
       
   904 
       
   905 // ---------------------------------------------------------
       
   906 // CConnectionInfoBase::ToStringStatusLC
       
   907 // ---------------------------------------------------------
       
   908 //
       
   909 HBufC* CConnectionInfoBase::ToStringStatusLC( TBool aIsDetailsView ) const
       
   910     {
       
   911     HBufC* status = NULL;
       
   912     TUint resourceId( 0 );
       
   913     switch ( iConnectionStatus )
       
   914         {
       
   915         case EConnectionCreated:
       
   916             {
       
   917             if ( iUpSpeed.quot || iUpSpeed.rem ||
       
   918                 iDownSpeed.quot || iDownSpeed.rem )
       
   919                 {
       
   920                 resourceId = aIsDetailsView ? R_QTN_CMON_STATUS_DETAILS_ACTIVE 
       
   921                                             : R_QTN_CMON_STATUS_ACTIVE;
       
   922                 }
       
   923             else
       
   924                 {
       
   925                 resourceId = aIsDetailsView ? R_QTN_CMON_STATUS_DETAILS_IDLE 
       
   926                                             : R_QTN_CMON_STATUS_IDLE;
       
   927                 }
       
   928             break;
       
   929             }
       
   930         case EConnectionUninitialized:
       
   931         case EConnectionClosed:
       
   932             {
       
   933             resourceId = aIsDetailsView ? R_QTN_CMON_STATUS_DETAILS_CLOSED 
       
   934                                         : R_QTN_CMON_STATUS_CLOSED;
       
   935             break;
       
   936             }
       
   937         case EConnectionClosing:
       
   938             {
       
   939             resourceId = aIsDetailsView ? R_QTN_CMON_STATUS_DETAILS_CLOSING 
       
   940                                         : R_QTN_CMON_STATUS_CLOSING;
       
   941             break;
       
   942             }
       
   943         case EConnectionSuspended:
       
   944             {
       
   945             resourceId = aIsDetailsView ? R_QTN_CMON_STATUS_DETAILS_SUSPENDED 
       
   946                                         : R_QTN_CMON_STATUS_SUSPENDED;
       
   947             break;
       
   948             }
       
   949         case EConnectionCreating:
       
   950         default :
       
   951             {
       
   952             resourceId = aIsDetailsView ? R_QTN_CMON_STATUS_DETAILS_CREATING 
       
   953                                         : R_QTN_CMON_STATUS_CREATING;
       
   954             break;
       
   955             }
       
   956         }
       
   957 
       
   958     status = StringLoader::LoadLC( resourceId );
       
   959 
       
   960     return status;
       
   961     }
       
   962     
       
   963     
       
   964 // ---------------------------------------------------------
       
   965 // CConnectionInfoBase::ToStringTotalTransmittedDataLC
       
   966 // ---------------------------------------------------------
       
   967 //
       
   968 HBufC* CConnectionInfoBase::ToStringTotalTransmittedDataLC() const
       
   969     {
       
   970     TUint total = iUploaded + iDownloaded;
       
   971     CMUILOGGER_WRITE_F( "iUploaded : %d", iUploaded );
       
   972     CMUILOGGER_WRITE_F( "iDownloaded : %d", iDownloaded );
       
   973     CMUILOGGER_WRITE_F( "total : %d", total );
       
   974     
       
   975     return ToStringLoadedDataLC( total );
       
   976     }
       
   977 
       
   978 // ---------------------------------------------------------
       
   979 // CConnectionInfoBase::ToStringSentDataLC
       
   980 // ---------------------------------------------------------
       
   981 //
       
   982 HBufC* CConnectionInfoBase::ToStringSentDataLC( TBool aToBeThreeDigit ) const
       
   983     {
       
   984     return ToStringLoadedDataLC( iUploaded, aToBeThreeDigit, KUpArrowChar );
       
   985     }
       
   986 
       
   987 
       
   988 // ---------------------------------------------------------
       
   989 // CConnectionInfoBase::ToStringReceivedDataLC
       
   990 // ---------------------------------------------------------
       
   991 //
       
   992 HBufC* CConnectionInfoBase::ToStringReceivedDataLC( TBool aToBeThreeDigit ) const
       
   993     {
       
   994     return ToStringLoadedDataLC( iDownloaded, aToBeThreeDigit, KDownArrowChar );
       
   995     }
       
   996 
       
   997 
       
   998 // ---------------------------------------------------------
       
   999 // CConnectionInfoBase::ToStringTransferSpeedUpLC
       
  1000 // ---------------------------------------------------------
       
  1001 //
       
  1002 HBufC* CConnectionInfoBase::ToStringTransferSpeedUpLC() const
       
  1003     {
       
  1004     return ToStringTransferSpeedLC( iUpSpeed, KUpArrowChar );
       
  1005     }
       
  1006 
       
  1007 
       
  1008 // ---------------------------------------------------------
       
  1009 // CConnectionInfoBase::ToStringTransferSpeedDownLC
       
  1010 // ---------------------------------------------------------
       
  1011 //
       
  1012 HBufC* CConnectionInfoBase::ToStringTransferSpeedDownLC() const
       
  1013     {
       
  1014     return ToStringTransferSpeedLC( iDownSpeed, KDownArrowChar );
       
  1015     }
       
  1016 
       
  1017 
       
  1018 // ---------------------------------------------------------
       
  1019 // CConnectionInfoBase::ToStringDurationLC
       
  1020 // ---------------------------------------------------------
       
  1021 //
       
  1022 HBufC* CConnectionInfoBase::ToStringDurationLC() const
       
  1023     {
       
  1024     const TUint KTimeStringLength = 64;
       
  1025     const TUint KTimeFormatBuf = 16;
       
  1026     const TUint KDateFormatBuf = 16;
       
  1027     _LIT( KDayFormat, "%d" );
       
  1028 
       
  1029 
       
  1030     TTime now;
       
  1031     now.UniversalTime();
       
  1032     HBufC* timeString = NULL;
       
  1033     
       
  1034     TTimeIntervalDays days = NULL;
       
  1035     
       
  1036     if  ( iStartTime != NULL )
       
  1037         {
       
  1038         // calculate days passed since connection started
       
  1039         days = now.DaysFrom( iStartTime );
       
  1040         CMUILOGGER_WRITEF( _L( "ToStringDurationLC days before: %d" ),
       
  1041                                days.Int() );
       
  1042         }
       
  1043     
       
  1044     // passed time since connection established.
       
  1045     if ( days.Int() <= 0 )
       
  1046         // it's still within 1 day
       
  1047         {
       
  1048         timeString = HBufC::NewLC( KTimeStringLength );
       
  1049         TPtr16 tempBuf( timeString->Des() );
       
  1050 
       
  1051         HBufC* temp = StringLoader::LoadLC( R_QTN_TIME_DURAT_LONG_WITH_ZERO );
       
  1052 
       
  1053         iDuration.FormatL( tempBuf, *temp );
       
  1054         CleanupStack::PopAndDestroy( temp );
       
  1055         }
       
  1056     else
       
  1057         // more than 1 day
       
  1058         {
       
  1059         CMUILOGGER_WRITEF( _L( "ToStringDurationLC days after: %d" ),
       
  1060                                days.Int() );
       
  1061             
       
  1062         TBuf<KDateFormatBuf>  dayFormat;
       
  1063         dayFormat.Format( KDayFormat, days.Int() );
       
  1064 
       
  1065         // format time format string
       
  1066         HBufC* tempFormat = StringLoader::LoadLC(
       
  1067                                             R_QTN_TIME_DURAT_SHORT_WITH_ZERO );
       
  1068         TBuf<KTimeFormatBuf> tempBuf;
       
  1069 
       
  1070         // format hours:mins
       
  1071         iDuration.FormatL( tempBuf, *tempFormat );
       
  1072 
       
  1073         CDesCArrayFlat* strings = new( ELeave ) CDesCArrayFlat( 2 );
       
  1074         CleanupStack::PushL( strings );
       
  1075 
       
  1076         strings->AppendL( dayFormat );
       
  1077         strings->AppendL( tempBuf );
       
  1078 
       
  1079         timeString = StringLoader::LoadL( R_QTN_CMON_DURATION_OVER_24H,
       
  1080                                           *strings );
       
  1081 
       
  1082         CleanupStack::PopAndDestroy( strings );
       
  1083         CleanupStack::PopAndDestroy( tempFormat );
       
  1084         CleanupStack::PushL( timeString );
       
  1085         }
       
  1086 
       
  1087     CMUILOGGER_WRITE_F( "duration time1: %S", timeString );
       
  1088     
       
  1089     TPtr temp( timeString->Des() );
       
  1090     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( temp );
       
  1091     CMUILOGGER_WRITE_F( "duration temp: %S", &temp );
       
  1092     
       
  1093     CMUILOGGER_WRITE_F( "duration time2: %S", timeString );
       
  1094     
       
  1095 
       
  1096     return timeString;
       
  1097     }
       
  1098 
       
  1099 
       
  1100 // ---------------------------------------------------------
       
  1101 // CConnectionInfoBase::CheckMrouterIap
       
  1102 // ---------------------------------------------------------
       
  1103 //
       
  1104 TBool CConnectionInfoBase::CheckMrouterIap()
       
  1105     {
       
  1106     CMUILOGGER_ENTERFN( "CheckMrouterIap" );
       
  1107     TBool result( ETrue );
       
  1108 
       
  1109     CMUILOGGER_WRITE_F( "IAP name: %S", &iConnectionName );
       
  1110     iConnectionName.Trim();
       
  1111     if ( iConnectionName.Left(
       
  1112                       KMrouterName().Length() ).CompareF( KMrouterName ) )
       
  1113         {
       
  1114         result = EFalse;
       
  1115         }
       
  1116     CMUILOGGER_LEAVEFN( "CheckMrouterIap" );
       
  1117     return result;
       
  1118     }
       
  1119 
       
  1120 
       
  1121 // ---------------------------------------------------------
       
  1122 // CConnectionInfoBase::ToStringLoadedDataLC
       
  1123 // ---------------------------------------------------------
       
  1124 //
       
  1125 HBufC* CConnectionInfoBase::ToStringLoadedDataLC( TUint aLoadedData, 
       
  1126                                                   TBool aToBeThreeDigit, 
       
  1127                                                   const TUint aArrowChar ) const
       
  1128     {
       
  1129     const TUint KTransferedBytesFormatBuf = 16;
       
  1130     const TUint KTransferedBytesWidth = 10;
       
  1131     TUint transferedBytesDecimalPlaces(2);
       
  1132     TUint resId;
       
  1133     HBufC* loadedTxt = NULL;
       
  1134 
       
  1135     TBuf<KTransferedBytesFormatBuf> buf;
       
  1136 
       
  1137     if ( aLoadedData < 1000 )          // bytes
       
  1138         {
       
  1139         if ( aToBeThreeDigit ) // added arrow to listbox
       
  1140             {
       
  1141             _LIT( KUdLinkFormatBytes, "%c%d" );
       
  1142 
       
  1143             buf.Format( KUdLinkFormatBytes, aArrowChar, aLoadedData );
       
  1144             }
       
  1145         else
       
  1146             {
       
  1147             _LIT( KUdLinkFormatBytes, "%d" );
       
  1148 
       
  1149             buf.Format( KUdLinkFormatBytes, aLoadedData );
       
  1150             }
       
  1151         resId = R_QTN_LOG_GPRS_AMOUNT_B;
       
  1152         }
       
  1153     else
       
  1154         {                           // KB, MB, GB
       
  1155         TUint denom;
       
  1156 
       
  1157         if ( aLoadedData < 1000 * 1024 )
       
  1158             {
       
  1159             denom = 1024;
       
  1160             resId = R_QTN_LOG_GPRS_AMOUNT_KB;
       
  1161             }
       
  1162         else if ( aLoadedData < 1000 * 1024 * 1024 )
       
  1163             {
       
  1164             denom = 1024 * 1024;
       
  1165             resId = R_QTN_LOG_GPRS_AMOUNT_MB;
       
  1166             }
       
  1167         else
       
  1168             {
       
  1169             denom = 1024 * 1024 * 1024;
       
  1170             resId = R_QTN_LOG_GPRS_AMOUNT_GB;
       
  1171             }
       
  1172 
       
  1173         TReal value = STATIC_CAST( TReal, aLoadedData ) /
       
  1174                       STATIC_CAST( TReal, denom );
       
  1175                       
       
  1176 		if ( aToBeThreeDigit )
       
  1177 			{
       
  1178 			if ( value < 10 )	// number of decimal places
       
  1179 				{
       
  1180 				transferedBytesDecimalPlaces = 2;
       
  1181 				}
       
  1182 			else if ( value < 100 )
       
  1183 				{
       
  1184 				transferedBytesDecimalPlaces = 1;
       
  1185 				}
       
  1186 			else
       
  1187 				{
       
  1188 				transferedBytesDecimalPlaces = 0;
       
  1189 				}
       
  1190 			}
       
  1191 
       
  1192 		TRealFormat Format( KTransferedBytesWidth, 
       
  1193 							transferedBytesDecimalPlaces );
       
  1194 
       
  1195         HBufC* number = HBufC::NewLC( KTransferedBytesWidth );
       
  1196         number->Des().Num( value, Format );
       
  1197 
       
  1198         if ( aToBeThreeDigit ) // added arrow to listbox
       
  1199             {
       
  1200             _LIT( KUdFormatLarge, "%c%S" );
       
  1201             buf.Format( KUdFormatLarge, aArrowChar, number );
       
  1202             }
       
  1203         else
       
  1204             {
       
  1205             _LIT( KUdFormatLarge, "%S" );
       
  1206             buf.Format( KUdFormatLarge, number );
       
  1207             }
       
  1208         CleanupStack::PopAndDestroy( number );
       
  1209         }
       
  1210 
       
  1211     loadedTxt = StringLoader::LoadLC( resId, buf );
       
  1212 
       
  1213     TPtr temp( loadedTxt->Des() );
       
  1214     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( temp );
       
  1215 
       
  1216     return  loadedTxt;
       
  1217     }
       
  1218 
       
  1219 
       
  1220 // ---------------------------------------------------------
       
  1221 // CConnectionInfoBase::ToStringTransferSpeedLC
       
  1222 // ---------------------------------------------------------
       
  1223 //
       
  1224 HBufC* CConnectionInfoBase::ToStringTransferSpeedLC( div_t aSpeed,
       
  1225                                                const TUint aArrowChar ) const
       
  1226     {
       
  1227     const TUint KUpDownSpeedBufSize = 16;
       
  1228     _LIT( KUdSpeedFmt, "%c%d%S%02d" );
       
  1229 
       
  1230     TBuf<KUpDownSpeedBufSize> buf;
       
  1231     TInt resId;
       
  1232 
       
  1233     HBufC* decSep = StringLoader::LoadLC( R_TEXT_CALC_DECIMAL_SEPARATOR );
       
  1234 
       
  1235     resId = R_QTN_CMON_DATA_TRANSF_RATE_UL;
       
  1236     buf.Format( KUdSpeedFmt, aArrowChar, aSpeed.quot, decSep, aSpeed.rem );
       
  1237 
       
  1238     CleanupStack::PopAndDestroy( decSep );
       
  1239 
       
  1240     HBufC* speedTxt = StringLoader::LoadLC( resId, buf );
       
  1241 
       
  1242     TPtr temp( speedTxt->Des() );
       
  1243     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( temp );
       
  1244 
       
  1245     return speedTxt;
       
  1246     }
       
  1247 
       
  1248 // ---------------------------------------------------------
       
  1249 // CConnectionInfoBase::InitializeConnectionInfoL
       
  1250 // ---------------------------------------------------------
       
  1251 //
       
  1252 void CConnectionInfoBase::InitializeConnectionInfoL()
       
  1253     {
       
  1254     CMUILOGGER_WRITE( "InitializeConnectionInfoL - start " );
       
  1255     TConnMonTimeBuf timeBuf;
       
  1256     iActiveWrapper->StartGetConnTime( iConnectionId,
       
  1257                                       iConnectionMonitor,
       
  1258                                       timeBuf );
       
  1259     TInt err( iActiveWrapper->iStatus.Int() );
       
  1260     CMUILOGGER_WRITE_F( "IntiConnectionInfo() status: %d", err );
       
  1261     if ( err != KErrNone )
       
  1262         {
       
  1263         User::Leave( err );
       
  1264         }
       
  1265 
       
  1266     iStartTime = timeBuf();
       
  1267     TDateTime dt = iStartTime.DateTime();
       
  1268     CMUILOGGER_WRITE_F( "Day : %d", dt.Day() );
       
  1269     CMUILOGGER_WRITE_F( "Hour : %d", dt.Hour() );
       
  1270     CMUILOGGER_WRITE_F( "Minute : %d", dt.Minute() );
       
  1271     CMUILOGGER_WRITE_F( "Second : %d", dt.Second() );
       
  1272     
       
  1273     
       
  1274     RefreshDetailsL();
       
  1275     if ( !iDetailsArray )
       
  1276         {
       
  1277         ToArrayDetailsL();
       
  1278         }
       
  1279     CMUILOGGER_WRITE( "InitializeConnectionInfoL - end " );
       
  1280     }
       
  1281 
       
  1282 // ---------------------------------------------------------
       
  1283 // CConnectionInfoBase::StringMarkerRemoval
       
  1284 // ---------------------------------------------------------
       
  1285 //
       
  1286 void CConnectionInfoBase::StringMarkerRemoval( HBufC* aStringHolder )
       
  1287     {
       
  1288     TPtr bufPtr = aStringHolder->Des();
       
  1289     
       
  1290     const TText KLRMarker = 0x200E;
       
  1291     const TText KRLMarker = 0x200F;
       
  1292 
       
  1293     TBuf<2> markers;
       
  1294     markers.Append( KLRMarker );
       
  1295     markers.Append( KRLMarker );
       
  1296 
       
  1297     // This function is requested to remove directional markers, because they
       
  1298     // cause a display error in languages such Hebrew. Directional markers will
       
  1299     // be correctly added later, when the one or two parts of the time string 
       
  1300     // are merged, again with StringLoader functions.
       
  1301     AknTextUtils::StripCharacters( bufPtr, markers ); 
       
  1302     }
       
  1303     
       
  1304 // ---------------------------------------------------------
       
  1305 // CConnectionInfoBase::ToStringAppNameLC
       
  1306 // ---------------------------------------------------------
       
  1307 //
       
  1308 HBufC* CConnectionInfoBase::ToStringAppNameLC( TInt aAppIndex )
       
  1309     {
       
  1310     HBufC* appName = ( iAppNames->MdcaPoint( aAppIndex ) ).AllocLC();
       
  1311     
       
  1312     return appName;
       
  1313     }
       
  1314 
       
  1315 // ---------------------------------------------------------
       
  1316 // CConnectionInfoBase::GetDeletedFromCMUI
       
  1317 // ---------------------------------------------------------
       
  1318 //
       
  1319 TBool CConnectionInfoBase::GetDeletedFromCMUI() const
       
  1320 	{
       
  1321 	return iDeletedFromCMUI;	
       
  1322 	}
       
  1323 
       
  1324 // ---------------------------------------------------------
       
  1325 // CConnectionInfoBase::SetAllDeletedFromCMUI
       
  1326 // ---------------------------------------------------------
       
  1327 //
       
  1328 void CConnectionInfoBase::SetAllDeletedFromCMUI()
       
  1329 	{
       
  1330 	iConnectionStatus = EConnectionClosing;
       
  1331 	}
       
  1332 
       
  1333 // ---------------------------------------------------------
       
  1334 // CConnectionInfoBase::SetDeletedFromCMUI
       
  1335 // ---------------------------------------------------------
       
  1336 //
       
  1337 void CConnectionInfoBase::SetDeletedFromCMUI()
       
  1338 	{
       
  1339 	iConnectionStatus = EConnectionClosing;
       
  1340 	
       
  1341 	iDeletedFromCMUI = ETrue;	
       
  1342 	}
       
  1343 
       
  1344 
       
  1345 // End of File